Re: Is $a an interger?

From: Date: Tue, 07 Nov 2000 17:08:32 +0000
Subject: Re: Is $a an interger?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24125@lists.php.net to get a copy of this message
At 11:41 7-11-00 -0500, L.T. Harris wrote:
Hi folks, this probably qualifies as a dumb newbie question. I want to use PHP to make sure a value submitted in a form is an integer, if not I want to prompt the user to change that value. However I have discovered that no matter what I do PHP thinks values submitted from the form are strings. I tired using settype() but that changes the value to 0, and when the form is resubmitted the type changes again to string. My brilliant (but non functional code) is\ $type=gettype($var1); if ($type=="integer") ... } else {
    if ($type="string") {
        settype($var1, "integer")
        ...//stuff to show form again
    }
} What do I need to do to make PHP think the values submitted by the form are integers Thanks,
Nothing Just do if ($a = 1) {
        // do stuff
} elseif ($a = "blah") {
        // do stuff
} Read the manual about (auto) type conversion Greetz, Wico
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#24125) next »