TechniqueEither set the error_reporting level in your php.ini file or use the error_reporting function to set an E_WARNING level of tolerance: <?php error_reporting(E_WARNING); $line = "maray"; ereg("(marray", $line, $ar); // Invalid Regex ?> CommentsThe error_reporting() function is very useful for detecting blatant errors in your regular expressions such as the error here (a missing closing parenthesis). However, do note that error_reporting() is not a complete syntax checker, so your code is still subject to many mistakes and exploits. The error_reporting() function should be used purely for debugging rather than for validating users' regular expressions. It does not check whether the regular expression makes sense, but rather whether the regular expression displays valid syntax. When you create programs, you should always set error_reporting() to the most stringent level possible ( E_ALL ). Then when the program is done with testing, you can lower the level of error_reporting() . |