note 91282 added to function.is-int
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 03 Jun 2009 15:39:55 +0000 |
| Subject: | note 91282 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156331@lists.php.net to get a copy of this message | ||
Typecasting will return false if a string has leading zeroes. If you prefer '023' return
true, try:
<?php
function really_is_int($val)
{
if(func_num_args() !== 1)
exit(__FUNCTION__.'(): not passed 1 arg');
return ($val !== true) && ((string)abs((int) $val)) === ((string) ltrim($val,
'-0'));
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 71.55.194.135
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/91282
Del: integrated -- https://master.php.net/note/delete/91282/integrated
Del: useless -- https://master.php.net/note/delete/91282/useless
Del: bad code -- https://master.php.net/note/delete/91282/bad+code
Del: spam -- https://master.php.net/note/delete/91282/spam
Del: non-english -- https://master.php.net/note/delete/91282/non-english
Del: in docs -- https://master.php.net/note/delete/91282/in+docs
Del: other reasons-- https://master.php.net/note/delete/91282
Reject -- https://master.php.net/note/reject/91282
Search -- https://master.php.net/manage/user-notes.php