note 118149 added to function.is-int
| From: | romanitalian dot net at gmail dot com | Date: | Wed, 14 Oct 2015 12:37:17 +0000 |
| Subject: | note 118149 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203957@lists.php.net to get a copy of this message | ||
<?php
function isInt($var) {
return is_int(filter_var($var, FILTER_VALIDATE_INT));
}
function isInt2($var) {
return is_numeric($var) ? (float)(int)$var===(float)$var : false;
}
$vars = array(0, '0', '234', '.34', '4.34',
'asdfasdf');
var_dump('isInt');
foreach($vars as $var) {
var_dump($var, isInt($var), '----------');
}
var_dump('is_numeric');
foreach($vars as $var) {
var_dump($var, is_numeric($var), '----------');
}
var_dump('isInt2');
foreach($vars as $var) {
var_dump($var, isInt2($var), '----------');
}
----
Server IP: 72.52.91.14
Probable Submitter: 109.238.244.74
----
Manual Page -- http://php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/118149
Del: integrated -- https://master.php.net/note/delete/118149/integrated
Del: useless -- https://master.php.net/note/delete/118149/useless
Del: bad code -- https://master.php.net/note/delete/118149/bad+code
Del: spam -- https://master.php.net/note/delete/118149/spam
Del: non-english -- https://master.php.net/note/delete/118149/non-english
Del: in docs -- https://master.php.net/note/delete/118149/in+docs
Del: other reasons-- https://master.php.net/note/delete/118149
Reject -- https://master.php.net/note/reject/118149
Search -- https://master.php.net/manage/user-notes.php