note 15116 deleted from function.is-int by jimw
| From: | jimw@php.net | Date: | Thu, 20 Dec 2001 23:34:54 +0000 |
| Subject: | note 15116 deleted from function.is-int by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23579@lists.php.net to get a copy of this message | ||
PHP 4 treads strings as folows:
"abc" * 1 == 0
25 * 1 == 25
etc.
So u cannot use the if ( is_int($id * 1) ) because if $id is a string the result of ($id * 1) is 0.
So i use this:
if ( ($id * 1 <> 0) or ($id == "0") ) {
echo "$id is a number";
} else { echo "$id is not a number"; }
It works if $id is set in the address bar or in a form.