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

From: Date: Wed, 06 Aug 2003 17:02:10 +0000
Subject: Re: Re: why doesn't default values for this function work
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-158515@lists.php.net to get a copy of this message
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.
But I want to make the same things, with some additions if $max_length is set. That's why I start with the check if($max_length > -1). function secure_string($unsafe_string, $max_length = -1, $errormessage = "Du har skrivit för många tecken.") { if($max_length > -1) { do stuff that's have to be done when $max_length is set } do stuff that's have to be done wether $max_length is set or not } Is there really something wrong with this logic (since it doesn't work, it obvious is, but what)? -- anders thoresson

« previous php.general (#158515) next »