Error Reporting in PHP

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 19:10, 23 May 2007 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

If error_reporting is off in the php.ini file, the above will ONLY WORK if you do the following:

Turning on error_reporting will not work for the same php file those lines are in, so you have to create a dummy index file, and then use 'require' to include your files with the code in them.

example

index.php contains:

<?php
  ini_set('error_reporting', E_ALL);
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  require('program.php');
?>

Then you start coding your program in program.php

This is stupid and annoying, so complain to the folks at Zend.

notices may be annoying for some. you may want to disable them. E_ALL ^E_NOTICE

ini_set('error_reporting', E_ALL ^E_NOTICE);

I recommend leaving it on, it helps to teach good programming practices.