Re[3]: [PHP] Validating form field text input to be a specific variable type

From: Date: Wed, 07 Apr 2004 02:11:08 +0000
Subject: Re[3]: [PHP] 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-182585@lists.php.net to get a copy of this message
MD>> if ( (int)$PageOptions['Default'] == $PageOptions['Default'] ) { Sorry, forgot to add that also bear in mind that the comparison operator == will automatically cast your string to an integer for the comparison. The following will take a user string ($str) and check if it is an integer or not. <? $str = "5.0a"; $v = intval($str); if ("$v" === "$str") { echo "Integer"; } else { echo "Something else"; } ?> -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#182585) next »