note 110087 added to class.errorexception
| From: | xianrenbatgmaildotcom | Date: | Tue, 18 Sep 2012 06:40:58 +0000 |
| Subject: | note 110087 added to class.errorexception | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190857@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.199
Probable Submitter: 124.244.171.10
----
Manual Page -- http://www.php.net/manual/en/class.errorexception.php
Edit -- https://master.php.net/note/edit/110087
Del: integrated -- https://master.php.net/note/delete/110087/integrated
Del: useless -- https://master.php.net/note/delete/110087/useless
Del: bad code -- https://master.php.net/note/delete/110087/bad+code
Del: spam -- https://master.php.net/note/delete/110087/spam
Del: non-english -- https://master.php.net/note/delete/110087/non-english
Del: in docs -- https://master.php.net/note/delete/110087/in+docs
Del: other reasons-- https://master.php.net/note/delete/110087
Reject -- https://master.php.net/note/reject/110087
Search -- https://master.php.net/manage/user-notes.php