note 15116 added to function.is-int

From: Date: Tue, 28 Aug 2001 17:24:19 +0000
Subject: note 15116 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-17257@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. http://www.php.net/manual/en/function.is-int.php

« previous php.notes (#17257) next »