note 110821 deleted from errorfunc.constants by danbrown
| From: | danbrown@php.net | Date: | Wed, 12 Dec 2012 16:12:43 +0000 |
| Subject: | note 110821 deleted from errorfunc.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192497@lists.php.net to get a copy of this message | ||
Note Submitter: dtccampbell at msn dot com
----
Here is a handly object which will return the error type name without having to hard-code it...
list($errno,$errstr,$errfile,$errline,$errcontext)=\func_get_args();
$o=(object)\get_defined_constants(1);
\array_map(function($v,$k)use(&$o){if(!\preg_match("#^E_#",$k))unset($o->Core[$k]);},$o->Core,\array_keys($o->Core));
$core_constants=\array_flip($o->Core);
$error_type=$core_constants[$errno];