It's a string, not an integer. Try using is_numeric() instead. To see
what type it is, do this :
echo gettype($phonenumber); // prints string
You may want to strip all non-numbers first, just in case they enter :
333-333-3333
Something like :
$phonenumber = preg_replace('/[^0-9]/','',$phonenumber);
Btw, $string = '3'; // is a string.
$number = 3; // is an integer
regards,
philip
On Sat, 28 Apr 2001, Jamie Saunders wrote:
>
> Hi,
>
> I'm submitting a phone number from an HTML form to a PHP page that examines
> it to see if it's an integer:
>
> form.html:
>
> <html>
> <form method="get" action="validate.php">
> <input type="text" name="phonenumber">
> <input type="submit">
> </form>
>
> validate.php:
>
> <html>
> <?php
>
> $phonenumber = trim($phonenumber);
>
> if (is_int($phonenumber)) {
> echo "Integer";
> } else {
> echo "Not Integer";
> }
>
> ?>
>
> </html>
>
>
> However, for some reason the script doesn't recognize the number as an
> Integer - why is this and how can I remedy it?
>
>
> Jamie Saunders
> Mail: [EMAIL PROTECTED]
> Web: http://jamie-s.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]