When I first started working with PHP, I really wanted a feature that worked like the -w switch in Perl. Being a bit of a noob, it took me a while to figure out the feature could be set using the
error_reporting function. You can set the PHP warnings level using the
php.ini file, but its much easier and preferable to just turn the feature on in individual scripts. This can be done as follows.
1:<?php 2:/** 3:Runnin this should generate an undeclared variable error 4: */ 5: 6:error_reporting(E_ALL); 7: 8:echo $undeclared; 9:?>
That is all there is too it. Any undeclared variable like that on line 8 will generate an error. Very useful for finding typos. Which I make a lot of. :)