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
From: anders thoresson [EMAIL PROTECTED]
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
function secure_string($unsafe_string, $max_length)
{
if(!is_int($max_length))
error(Variable max_length is not an integer. );
if (strlen($unsafe_string) $max_length)
error(Too many characters.);
}
I want the $max_length to be optional. With your solution it isn't? I
thought I could make it
Anders Thoresson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi,
I'm having problem with a function that I'll use to validate user input
before passing it to MySQL. For strings, I want to make sure that they
aren't to long, so I have written this function:
function
4 matches
Mail list logo