Re: Re: why doesn't default values for this function work

From: Date: Tue, 05 Aug 2003 19:19:51 +0000
Subject: Re: Re: why doesn't default values for this function work
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-158334@lists.php.net to get a copy of this message
From: "anders thoresson" <listor@thoresson.net> > I want the $max_length to be optional. With your solution it isn't? I > thought I could make it optional by assigning a default value of -1, which > would tell the function not to bother with max_length and continue the > execution. > > All in all my function looks like this (crossing my fingers and hopes that > linewrap works this time): > > function secure_string($unsafe_string, $max_length = -1, $errormessage = > "Du har skrivit för många tecken.") > { > // verify that string isn't longer then $max_length, if $max_length is set > if ($max_length > -1) Change your logic here... if($max_length == -1) then you did not send a value for $max_length and act accordingly. or if(!($max_length == -1)) you did send a $max_length value and act accordingly. ---John Holmes...

« previous php.general (#158334) next »