PHP_DEBUG a very handy little constant

I was browsing through php.net this morning whilst waiting on my turn in the bathroom (true story!) because I was looking for some more information on PHP_EOL.

During my search I ran into the PHP constants list which had a reference to PHP_DEBUG.

I did some searching around to see if I could find out more about this little constant and basically it is a variable you can set either in your virtualhost or using htaccess to tell the server if you should be in debug mode or not.  By default it is set to zero so what you can do is add code like this into your script.

if (getenv('PHP_DEBUG')=='1')
{
  error_reporting( E_ERROR | E_USER_ERROR );
  ini_set( 'display_errors', true );
}
else
{
  error_reporting( E_ERROR | E_USER_ERROR );
  ini_set( 'display_errors', false );
}

Pretty cool, huh?

Recent posts View all

Conferences

Tips for how to ask for time off to attend conferences

Asking for time off to attend a conference can be nerve-racking, these tips will get you closer to attending the conferences you're interested in.

Ruby

Using the 'it' Gem to add links to translations

How to can use the 'it' Gem to add links to your translations