Jump to content

Error handler class error


next

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/116233-error-handler-class-error/
Share on other sites

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)) {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.