note 100300 added to function.is-string
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 06 Oct 2010 16:48:37 +0000 |
| Subject: | note 100300 added to function.is-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173035@lists.php.net to get a copy of this message | ||
Actually, the reason for the difference in son9ne's examples is this:
Through PHP's loose typing an empty string is both int 0 & boolean false. Switch on string
is rendering the empty string to false, so the switch matches the false of is_array() not the true
of is_string() !!!
Also, through loose typing a string without leading non-zero numbers is both int 0 & boolean
true (oddly enough, it is both true & false at the same time). But in the case of non-empty
strings with no leading digits, switch works as expected rendering the numberless string to boolean
true not int 0 false, so the switch matches the true of is_string() not the false of is_array() !!!
$test = " ";
var_dump((int) $test);
var_dump((bool) $test);
var_dump((bool) (int) $test);
var_dump((bool) (bool) $test);
----
Server IP: 69.147.83.197
Probable Submitter: 204.137.29.243
----
Manual Page -- http://www.php.net/manual/en/function.is-string.php
Edit -- https://master.php.net/note/edit/100300
Del: integrated -- https://master.php.net/note/delete/100300/integrated
Del: useless -- https://master.php.net/note/delete/100300/useless
Del: bad code -- https://master.php.net/note/delete/100300/bad+code
Del: spam -- https://master.php.net/note/delete/100300/spam
Del: non-english -- https://master.php.net/note/delete/100300/non-english
Del: in docs -- https://master.php.net/note/delete/100300/in+docs
Del: other reasons-- https://master.php.net/note/delete/100300
Reject -- https://master.php.net/note/reject/100300
Search -- https://master.php.net/manage/user-notes.php