Re: Str to Int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> if ($cardID=''||is_int($cardID))

Two problems with that statement:
First of all, this statement _sets_ cardID to '', and then (I think)
returns a false value since '' doesn't evaluate to true.  You probably
wanted ==.
Second of all, now that $cardID is '', it certainly isn't an int.  It
isn't an int, and it wouldn't be an int if you fixed that statement
because is_int only tests if it is, actually, an integer. 
$HTTP_GET_VARS['cardID'] could be '123', but it can't be 123 and so
that will be false.  From the PHP manual:

    Note:  To test if a variable is a number or a numeric string (such
as form input, which is always a string), you must use is_numeric().

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux