Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.