note 109100 deleted from function.is-int by danbrown
| From: | danbrown@php.net | Date: | Tue, 26 Jun 2012 14:03:32 +0000 |
| Subject: | note 109100 deleted from function.is-int by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188855@lists.php.net to get a copy of this message | ||
Note Submitter: Bionic
----
Simple checking for integer, fixed version:
<?php
if (strval(intval($var)) === strval($var)) {
// $var is integer
}
?>
the difference is the 3 equal signs (identical, instead of equal) since strings with a plus or minus
in front of them might otherwise falsely be evaluated the same as one without.