views:

20

answers:

2

What settings to change while setting up php WAMP so that undefined variable error is not encountered. I changed setting of register_globals = on but it did not help.

A: 

Try a clean installation and be very careful not to not modify any part of the actual variable that might result in unsetting it. Just the settings part of the variable should be changed. Also, a bit more information might be helpful to us.

Nik
A: 

You are probably looking for this php.ini setting:

error_reporting = error_reporting = E_ALL & ~E_NOTICE 

it should be the default setting in a fresh install, though.

The best way, however, is always to change your scripts so undefined variable notices aren't thrown in the first place.

Notices sometimes contain valuable information that is impossible to find in a sea of meaningless "undefined variable" notices; and even if notices and warnings are suppressed, they slow down the script's execution! So the right thing is to prevent them from the start if at all possible.

You can check for the existence of each variable using isset() or empty() before using it to prevent undefined variable notices from happening.

Pekka
Hello Pekka, It worked. thank you very much.
Nishant