• Saran

  • Saran Chamling loves the web technology, and enjoys designing, exploring and writing about it @sanwebe.com. You can find him at Twitter, Google or Facebook.

Saran's Article(s)

  • Microsoft Access using PHP PDO

    Microsoft Access database is not a preferred choice to store sensitive or large amount of data, because it is not so robust as other database, you will soon discover several limitation as your database size grows. However for small business and individuals Access database is ideal alternative, it is cheap to setup and simple to use! Let’s find out how easily we can play with Access database using PHP PDO.
  • Randomized quote display PHP

    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.
  • PHP Download file snippet

    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');
  • Return Currency Symbols using PHP

    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.