note 90198 added to function.is-int

From: Date: Thu, 09 Apr 2009 15:27:26 +0000
Subject: note 90198 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-153025@lists.php.net to get a copy of this message
Simon Neaves was close on explaining why his function is perfect choice for testing for an int (as possibly most people would need). He made some errors on his ctype_digit() output though - possibly a typo, or maybe a bug in his version of PHP at the time. The correct output for parts of his examples should be: var_dump(ctype_digit(23)); //bool(false) var_dump(ctype_digit("23")); //bool(true) var_dump(ctype_digit(23.5)); //bool(false) var_dump(ctype_digit(NULL)); //bool(false) var_dump(ctype_digit("")); //bool(false) As you can see, the reason why using *just* ctype_digit() may not always work is because it only returns TRUE when given a string as input - given a number value and it returns FALSE (which may be unexpected). ---- Server IP: 69.147.83.197 Probable Submitter: 99.241.132.158 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/90198 Del: integrated -- https://master.php.net/note/delete/90198/integrated Del: useless -- https://master.php.net/note/delete/90198/useless Del: bad code -- https://master.php.net/note/delete/90198/bad+code Del: spam -- https://master.php.net/note/delete/90198/spam Del: non-english -- https://master.php.net/note/delete/90198/non-english Del: in docs -- https://master.php.net/note/delete/90198/in+docs Del: other reasons-- https://master.php.net/note/delete/90198 Reject -- https://master.php.net/note/reject/90198 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153025) next »