tags:

views:

42

answers:

2

How to configure PHP to emit warning when I try to read value of unset variable?

It is frequently happens when I rename variable in one place, I obtain weird result because I forgot to rename it in other place.

+4  A: 

Set error reporting to all and you will get info about any undefined variables too, for example, put this on top of your script:

ini_set('display_errors', true);
error_reporting(E_ALL);
Sarfraz
Is it possible to configure php.ini? I set up display_errors = On error_reporting = E_ALLBut this does not help
sergdev
A: 

It's not possible elevate the level of a notice, but you could create a custom error handling function.

You can build that handler in a way that it reacts only to "variable not set" type notices and outputs a message or sends an E-Mail or whatever.

All the other errors you could pass on to the default error handler by returning false in the custom error handler.

Pekka