note 77997 added to function.set-error-handler
| From: | michal dot kocarek at NO_SPAM dot seznam dot cz | Date: | Sun, 23 Sep 2007 09:55:04 +0000 |
| Subject: | note 77997 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130708@lists.php.net to get a copy of this message | ||
Be aware of efficiency and speed of your scripts!
If you use old-fashioned non-strict variable calling (example follows...), your custom error handler
function degrades the script speed very big (especially for bigger projects). Because of for every
"use of undefined constant" or "undefined variable" E_NOTICEs will be called
your own custom error handler function.
<?
if ($form_variable) { ///< E_NOTICE Undefined variable
// process form stuff
}
$foo[bar] = $const_array[baz]; ///< 2x E_NOTICE Use of undefined constant bar, baz
if (!$d) { // declare default $d ///< E_NOTICE Undefined variable
$d = 5;
}
?>
As you can see in this poor example, badly writted scripts decrease the performace very big
'cause of the error handler is called almost everytime. So use custom-error-handler on heavily
used pages only if you are writing scripts strictly. (Example follows:)
<?
if (isset($form_variable) && $form_variable != null) {
// process form stuff
}
$foo['bar'] = $const_array['baz'];
if (!isset($d) || $d == null) {
$d = 5;
}
?>
----
Server IP: 212.24.129.51
Probable Submitter: 83.208.62.60
----
Manual Page -- http://www.php.net/manual/en/function.set-error-handler.php
Edit -- https://master.php.net/note/edit/77997
Del: integrated -- https://master.php.net/note/delete/77997/integrated
Del: useless -- https://master.php.net/note/delete/77997/useless
Del: bad code -- https://master.php.net/note/delete/77997/bad+code
Del: spam -- https://master.php.net/note/delete/77997/spam
Del: non-english -- https://master.php.net/note/delete/77997/non-english
Del: in docs -- https://master.php.net/note/delete/77997/in+docs
Del: other reasons-- https://master.php.net/note/delete/77997
Reject -- https://master.php.net/note/reject/77997
Search -- https://master.php.net/manage/user-notes.php