I am currently recoding the bulk of my web site network. One major change is that I finally made a proper error handling system. To get right down to it, when you use a custom error handler, PHP ignores the error_reporting level you use. Because of this, all those little "undefined variable" and "undefined index" notices I never, well, noticed, will call my handler. Of course my handler is currently set to ignore them but it raises a burning question in my mind:
Is it more efficient from a performance standpoint to:
a.) Not use a custom error handler and let PHP do nothing with the notice errors other than notice them.
b.) User my custom error handler and have it ignore notices.
c.) Work empty() and isset() into my scripts ever-so gingerly.
?
I wish I knew more about the internals of the Zend Engine, but I assume that in order for PHP to designate something as a notice error, it has to call an internal function. Then it has to check the error handling rules and follow them. In cases a and b this would be routine, along with the added function of my error_handler being called in case b. Case c obviously involves lots of added function calls, as I've mentioned empty and isset, along with many new If statements. In some of my scripts, this could amount to lots of new function calls, however that also means that in cases a and b that means a lot of unnoticed errors.
I plan on doing some benchmark tests to see myself, but I'm not particularly good at that stuff. I'm hoping someone here can share any benchmarking they've done or even some theory to this. I'd be particularly delighted if someone with knowledge of the internals could set this straight.
I appreciate the help and I realize it is better practice to do case c, but as this code is for my eyes only (and I'm the one who has to redo everything should a 'better practice' become mandatory), I am only concerned with the performance, not the sound practice.
- Rob Paxon
P.S. (offtopic)
Speaking of benchmarking, in case anyone is interested I did some testing on the three string syntaxes (single, double, and hereto) with lots of variables and it seemed to me that using single string quotations is more efficient than the other two.
$string = 'Blah blah ' . $blah . ' blah blah'; as opposed to $string = "Blah blah $blah blah blah";
I'd like to dig deeper into this in the future, with varying amounts of variables per string.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php