note 87602 added to function.is-int
| From: | Ben at osu1 dot php dot net | Date: | Fri, 12 Dec 2008 15:57:20 +0000 |
| Subject: | note 87602 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148076@lists.php.net to get a copy of this message | ||
Why bother type checking when your casting both sides as strings.
Dont over-engineer it.
<?php
function another_is_int($a){
return ($a == (int) $a);
}
?>
# Don't over-engineer it.
#
# <?php
# function another_is_int($a){
# return ((string) $a) === ((string)(int) $a);
# }
# ?>
----
Server IP: 117.104.160.194
Probable Submitter: 220.233.181.142
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/87602
Del: integrated -- https://master.php.net/note/delete/87602/integrated
Del: useless -- https://master.php.net/note/delete/87602/useless
Del: bad code -- https://master.php.net/note/delete/87602/bad+code
Del: spam -- https://master.php.net/note/delete/87602/spam
Del: non-english -- https://master.php.net/note/delete/87602/non-english
Del: in docs -- https://master.php.net/note/delete/87602/in+docs
Del: other reasons-- https://master.php.net/note/delete/87602
Reject -- https://master.php.net/note/reject/87602
Search -- https://master.php.net/manage/user-notes.php