note 109100 added to function.is-int
| From: | Bionic | Date: | Wed, 20 Jun 2012 15:27:22 +0000 |
| Subject: | note 109100 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188718@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 80.67.0.53
Probable Submitter: 83.248.205.46
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/109100
Del: integrated -- https://master.php.net/note/delete/109100/integrated
Del: useless -- https://master.php.net/note/delete/109100/useless
Del: bad code -- https://master.php.net/note/delete/109100/bad+code
Del: spam -- https://master.php.net/note/delete/109100/spam
Del: non-english -- https://master.php.net/note/delete/109100/non-english
Del: in docs -- https://master.php.net/note/delete/109100/in+docs
Del: other reasons-- https://master.php.net/note/delete/109100
Reject -- https://master.php.net/note/reject/109100
Search -- https://master.php.net/manage/user-notes.php