note 91633 added to function.is-int
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 20 Jun 2009 13:21:31 +0000 |
| Subject: | note 91633 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157173@lists.php.net to get a copy of this message | ||
Anonymous's 3-Jun note was on the right track by not typecasting, but didn't work for 0,
"0", "00", -1... A slight variation of Mark's 26-Jun note is the best yet:
<?php
function really_is_integer($val)
{
return ((preg_match('/^[-]?[0-9]+$/', $val) === 1) and !is_bool($val));
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 69.69.21.91
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/91633
Del: integrated -- https://master.php.net/note/delete/91633/integrated
Del: useless -- https://master.php.net/note/delete/91633/useless
Del: bad code -- https://master.php.net/note/delete/91633/bad+code
Del: spam -- https://master.php.net/note/delete/91633/spam
Del: non-english -- https://master.php.net/note/delete/91633/non-english
Del: in docs -- https://master.php.net/note/delete/91633/in+docs
Del: other reasons-- https://master.php.net/note/delete/91633
Reject -- https://master.php.net/note/reject/91633
Search -- https://master.php.net/manage/user-notes.php