Re: Odd Code Error.

From: Date: Wed, 21 Jan 2004 23:36:04 +0000
Subject: Re: Odd Code Error.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-175362@lists.php.net to get a copy of this message
daniel@electroteque.org wrote:
Hmm i was checking out a pear class, what about the variables within a function ? like function foo($name) { if ($name) { } } or foo($name) { if (isset($name)) { } } it uses isset on variables coming outside the function
Those examples don't make much sense. Without a default value, if foo() is called without a parameter, then it'll cause an error. So, obviously $name is going to be set. So isset() will always be true. if($name) is a valid check, I guess, since an empty string or zero could be passed and cause that to fail. It'd make more sense to set a default value for $name or check for an actual value instead of just seeing if (boolean)$name is TRUE or FALSE. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#175362) next »