note 87670 added to function.is-int

From: Date: Tue, 16 Dec 2008 08:08:23 +0000
Subject: note 87670 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-148203@lists.php.net to get a copy of this message
another_is_int() is almost perfect, but it treats boolean true as int because 1 == (int) true == (string) true == '1'. Fixed version: <?php /** * Checks if the given value represents integer */ function int_ok($val) { return ($val !== true) && ((string)(int) $val) === ((string) $val); } ?> ---- Server IP: 195.54.192.44 Probable Submitter: 127.0.0.1 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/87670 Del: integrated -- https://master.php.net/note/delete/87670/integrated Del: useless -- https://master.php.net/note/delete/87670/useless Del: bad code -- https://master.php.net/note/delete/87670/bad+code Del: spam -- https://master.php.net/note/delete/87670/spam Del: non-english -- https://master.php.net/note/delete/87670/non-english Del: in docs -- https://master.php.net/note/delete/87670/in+docs Del: other reasons-- https://master.php.net/note/delete/87670 Reject -- https://master.php.net/note/reject/87670 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148203) next »