Re: Validating form field text input to be a specific variable type

From: Date: Wed, 07 Apr 2004 12:54:05 +0000
Subject: Re: Validating form field text input to be a specific variable type
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-182614@lists.php.net to get a copy of this message
Instead of doing a lot of casting, you can use is_numeric() to see if a variable is a number or a numeric string. -William El mar, 06-04-2004 a las 14:19, John W. Holmes escribió: > Well, if "(int)$string == $string", then the value is an integer. Same for > "(float)$string == $string" for a real number. Boolean would be easy, just > strtolower($string) as compare to 1, 0, 'true', or 'false'. Date/time > validation will probaby require a regular expression or breaking it up to > validate days/month, etc. That can get a little hairy. If they say "text", > well, anything goes, right? Maybe just make sure it's not empty()? > > Let me know if you need more details. There are probably a ton of different > ways to do this. > > ---John Holmes...

« previous php.general (#182614) next »