Re: Odd Code Error.

From: Date: Thu, 22 Jan 2004 00:06:02 +0000
Subject: Re: Odd Code Error.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175365@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. I dont understand, i assume that would check if name was set, i also set functions like function foo($name,$bar = null) { } so therefore bar doesnt need to be inputted, seeing as i set it to null would i check if $bar===true ? or just isset($bar ) ?

« previous php.general (#175365) next »