next Posted July 23, 2008 Share Posted July 23, 2008 PHP: <?php // handles Errors class Error { //initialize error handling public static function engage($e_types = ERROR_TYPES) { return set_error_handler(array('Error', 'handler'), $e_types); } public static function handler($e_nbr, $e_str, $e_file, $e_line) { //generate message $e_msg = "\r\nError Number: $e_nbr on line $e_line<br />\r\nError Message: $e_str<br />\r\nLocation: $e_file<br />\r\nTime: " . date('F j, Y, g:i a'); //email ? if(EMAIL_ERROR) { error_log($e_msg, 1, ADMIN_EMAIL, 'From: ' . EMAIL_FROM); } // log errors to file ? if(LOG_ERROR) { error_log($e_msg, 3, LOG_PATH); } //regular errors don't abort application if($e_nbr == E_WARNING && IS_WARNING_FATAL == false) || ($e_nbr == E_NOTICE || $e_nbr == E_USER_NOTICE) { if(DEBUG_MODE) echo '<div class="error">' . $e_msg . '</div>'; } //fatal errors abort application else { if(DEBUG_MODE) echo '<div class="error">' . $e_msg . '</div>'; else echo '<div class="error">' . FRIENDLY_ERROR . '</div>'; exit(); } } } ?> For some reason PHP throws an error: Parse error: syntax error, unexpected T_BOOLEAN_OR in E:\PortableApps\WOS\www\MovieTalk\lib\error.class.php on line 23 line 23: if($e_nbr == E_WARNING && IS_WARNING_FATAL == false) || ($e_nbr == E_NOTICE || $e_nbr == E_USER_NOTICE) { I don't see an error here, can anyone help? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/116233-error-handler-class-error/ Share on other sites More sharing options...
redbullmarky Posted July 23, 2008 Share Posted July 23, 2008 try enclosing your conditions a little clearer. instead of: if($e_nbr == E_WARNING && IS_WARNING_FATAL == false) || ($e_nbr == E_NOTICE || $e_nbr == E_USER_NOTICE) { try if(($e_nbr == E_WARNING) && (IS_WARNING_FATAL == false)) || (($e_nbr == E_NOTICE) || ($e_nbr == E_USER_NOTICE)) { Quote Link to comment https://forums.phpfreaks.com/topic/116233-error-handler-class-error/#findComment-597685 Share on other sites More sharing options...
next Posted July 23, 2008 Author Share Posted July 23, 2008 Nah, it didn't work. For some reason PHP doesn't like IS_WARNING_FATAL constant i have it defined in my config file as: define('IS_WARNING_FATAL', true); If i remove it, my code works, but i would like to use this. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/116233-error-handler-class-error/#findComment-597690 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.