Re: Validating form field text input to be a specificvariable type

From: Date: Wed, 07 Apr 2004 21:49:04 +0000
Subject: Re: Validating form field text input to be a specificvariable type
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-182725@lists.php.net to get a copy of this message
They are typecasted to match the current contexts needs - often a problem but even - but this is one of PHPs strenghs :-) -- red William Lovaton wrote:
Yeah, sometimes this is an annoying problem with PHP. Somehow, "", null, 0 and "0" is the same thing. The last two are considered empty() too. -William El mi? 07-04-2004 a las 16:34, Red Wingate escribió:
JFYI : var_dump ( '' == 0 ) eq TRUE William Lovaton wrote:
I don't think so, Wouldn't be better if ctype_digit() return false on an empty string?? any way an empty string is not a digit. This change will brake backward compatibility so it is not an option. if you look carefully the function that you propose is doing two things at once... at this level this is not a good idea. -William El mi? 07-04-2004 a las 12:39, Red Wingate escribió:
No, as this would be yet another line of source. Maybe get those guys to add another function ctype_digit_and_not_empty(); -- red [...]
* Thus wrote William Lovaton (williama_lovaton@coomeva.com.co):
or modify is_numeric() to explictly perform an integer validation: is_numeric(mixed value [, bool is_integer = false])
um.. ctype_digit().
Very nice! it works fine. The only issue is that it will return true if the parameter is an empty string (""). Nothing that an empty() can't fix.
[...]


« previous php.general (#182725) next »