Re: php 4.0.2 and args in a function

From: Date: Fri, 01 Sep 2000 10:18:37 +0000
Subject: Re: php 4.0.2 and args in a function
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-14860@lists.php.net to get a copy of this message
James - Thanks for the reply. Yup, I've gone through most of my functions and started to assign default values, most likely a better way to code anyway. But I also had to change the code in the function. Previously I was using isset() to see if an argument was passed to the function. Setting the var to "" doesn't allow me to do this any more. Is isempty() the solution? -- Scott On Fri, Sep 01, 2000 at 07:56:44PM +0100, James Moore wrote: > > this is the way it should be done: > > 00 <? > 01 function smoosh($var1, $var2 = "") { /*Give $var2 a defauilt value > making it optional */ > 02 return $var1 . $var2; > 03 } > 04 ?> > 05 <HTML> > 06 <BODY> > 07 <? > 09 $onevar = smoosh("string1a","string2a"); > 10 print("<P>".$onevar); > 11 $twovar = smoosh("string1b"); > 12 print("<P>".$twovar); > 13 ?> > 14 </BODY> > 15 </HTML> > > > James

« previous php.general (#14860) next »