You can use example below in many different situations, idea is to create a list of quotes in array, and using PHP array_rand(), we can pick random entries out of an array.
Many of us like to share files publicly on our websites, pointing directly to downloadable contents! But this can be risky as you might be exposing stuff you wouldn’t want public to know. Instead of pointing to downloadable files directly, you can use this PHP snippet to force download them. This way the original file path will be hidden from the public and you’ll feel bit secure. Just copy paste this function into a PHP file and call it when needed.function force_download_a_file($dl_file) { if(is_file($dl_file)) { if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } header('Expires: 0'); header('Pragma: public'); header('Cache-Control: private',false); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="'.basename($dl_file).'"'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Last-Modified: '.gmdate ('D, d M Y H:i:s', filemtime ($dl_file)).' GMT'); header('Content-Length: '.filesize($dl_file)); header('Connection: close'); readfile($dl_file); die(); } }Usage : force_download_a_file('home/Websites/path/content.pdf');
I needed a PHP function that returns HTML Entity of currency codes, so I have written this small function with list of major currency symbols of the world, I hope this will be useful.
Are you looking for PHP pagination function? here one slick PHP function that will paginate your database records. You can easily combine this function in your project to paginate your database records. Just drop the function within your PHP script and call it wherever you’ll need the pagination.