4.3 Setting Breakpoints by Using PHP's Error Constants
TechniqueUse PHP's error_reporting() function in conjunction with the predefined error constants: <? error_reporting(E_WARNING); $line = "The\nQuick\nYoung\nProgrammer\nJumped\nOver\nThe\nLazy\nOld\ nProgrammer"; $line = ereg_replace("(\n"," ",$line); // mis-matched parentheses print $line; ?> CommentsIn this code, the regular expression in the first argument of ereg_replace() has a mismatched parenthesis (the correct syntax would be ereg_replace("(\ n)"," ", $line);) . Normally, PHP would not report this error, but because we told the PHP processor through the error_reporting() function that we want PHP to report regular expression errors, we now get the error reported to us. E_WARNING is just one of the different levels of error reporting. The following is a table of all the error constants.
Using these constants in conjunction with the error_reporting() function will help you better debug your scripts and find major flaws and quirks that PHP might not be reporting, but that are causing your program to act differently. The default error-reporting level is E_ALL & ~E_NOTICE (all errors except notices). |