note 110087 deleted from class.errorexception by googleguy

From: Date: Tue, 18 Sep 2012 18:18:06 +0000
Subject: note 110087 deleted from class.errorexception by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190864@lists.php.net to get a copy of this message
Note Submitter: xianrenb at gmail dot com ---- I am afraid the correct example should be: <?php function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); /* Trigger exception */ strpos(); ?> Reasons: 1. As in the manual page of set_error_handler(), $errno, contains the level of the error raised, as an integer, which is the same meaning as $severity in ErrorException. 2. $severity is the only property that class Exception does not have, but class ErrorException has. 3. $severity in ErrorException has a default value of 1, which is the same value as E_ERROR, but $code has a default value of 0. 4. Most comments from other contributors, if not all, use the first parameter of exception_error_handler() as the $severity parameter in the ErrorException constructor.

« previous php.notes (#190864) next »