Page 1 of 1

if(@$variable)

Posted: Mon Aug 09, 2010 6:56 pm
by bodya
I usually use syntax

Code: Select all

if(@$variable)
instead of

Code: Select all

if(isset($variable) && $variable)
The first variant is faster but is it correct? Thanks

Re: if(@$variable)

Posted: Mon Aug 09, 2010 8:41 pm
by josh
Nope. isset() returns true if the variable is set. the first one differs in that it will not run if the variable is set but set to false. Use isset(). Error suppression is never needed.

Re: if(@$variable)

Posted: Thu Aug 12, 2010 9:27 am
by Benjamin
:arrow: Moved to PHP - Code