PHP: Display errors

For security reasons, display_errors should be turned off in php.ini. This will not display the error on the browser.

However it’s inconvenient during development not being able to see the error and have to access error logs. This can be turned on with this code:

ini_set("display_errors", 1); 
error_reporting(E_ALL &&; ~E_NOTICE && E_WARNING);

This code should be removed / commented when put in production.

Color Scheme Generator

My biggest nightmare working on web development projects is trying to come up with a good color scheme for the site. I’m never a designer and I’m colorblind when it comes to this.

At work the graphic designer does the job, But when I’m on my own, I rely on this web-based color scheme generator.

Just select a color on the color wheel, click here and there, you can get some good color combinations out of it.

Update 26/05/09

This is still my favorite tool and i just discovered it has a new version – a better interface with sample site preview.

PHP: Stream Download

A general php code to download any type of file:

header("Content-Type: application/octet-stream"); 
header("Content-Length: " . filesize($filename)); 
header("Content-Disposition: attachment; filename=\"$filename\""); 

content-type defines the type of file being sent. application/octet-stream is used for any kind of files.

content-length indicates the size of information. this is to let browser know how much data to download in advance and ensure

content-disposition is used to suggest the file name to be saved. the filename should have the correct extension so that the browser knows the default application associated with this extension.