Re: Check for integer
| From: | Sebastian \"Archimedes\" Meyer | Date: | Mon, 26 May 2003 18:59:32 +0000 |
| Subject: | Re: Check for integer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149008@lists.php.net to get a copy of this message | ||
Try "is_int",
int is_int (mixed var), for further details look into the online reference.
<?php
$yourvar=$yourvar*10;
$yourvar=$yourvar/10;
if(is_integer($yourvar)==TRUE)
{
print("Var $yourvar is an integer");
}
else
{
print("Var $yourvar is <b>not</b> an integer");
}
?>
the *10 and the /10 is because php makes all vars given by
"file.php?yourvar=100" a string....
"Shaun" <shaun@mania.plus.com> wrote in message
news:20030526182401.14696.qmail@pb1.pair.com...
> Hi,
>
> how can I ensure that a variable sent from a form is an integer?
>
> Thanks for your help
>
>