Re: Re: PEAR Coding Standards

From: Date: Tue, 04 May 2004 01:08:45 +0000
Subject: Re: Re: PEAR Coding Standards
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-28752@lists.php.net to get a copy of this message
Thorsten Suckow-Homberg wrote:
------ GENERAL USAGE ------ there are times when checking variables where although it is minutely slower, it does aid readibility. if (@$options['dosomething'] == true) { is significantly clearer than if (isset($options['dosomething']) && ($options['dosomething'] == true)) { ..... ---------------------------------- @ is part of the language, and in some respects is just a short form of catch/try/throw.
I may be wrong here, but @ doesn't help you to get rid of Notices when you set error_reporting to E_ALL, am I right? Nope - it works perfectly..
If that is so, I think it is a bad
idea to spare your issets and instead using @'s...
Actually, there was considerable discussion on internals about this, and the idea of introducing a setor() method. @ is slower than "isset() && test" - significantly, when the majority of the the tests raise an error. (however, it is about the same when most of the time, the variable is set.) generally: ** if the variable is normally set: if (@$somevar==....) { is probably going to be marginally faster. (and is slightly more readable) ** if the variable is normally not set: if (isset($somevar) && $somevar == .... is probably going to be faster (this is based on the priniciple that someone is likely to have implemented a error_handler...) Regards Alan -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.dev (#28752) next »