note 85215 added to function.empty
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 20 Aug 2008 21:41:15 +0000 |
| Subject: | note 85215 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143686@lists.php.net to get a copy of this message | ||
To add on to what anon said, what's happening in john_jian's example seems unusual because
we don't see the implicit typecasting going on behind the scenes. What's really happening
is:
$a = '';
$b = 0;
$c = '0';
(int)$a == $b -> true, because any string that's not a number gets converted to 0
$b==(int)$c -> true, because the int in the string gets converted
and
$a==$c -> false, because they're being compared as strings, rather than integers.
(int)$a==(int)$c should return true, however.
Note: I don't remember if PHP even *has* typecasting, much less if this is the correct syntax.
I'm just using something for the sake of examples.
----
Server IP: 64.71.164.2
Probable Submitter: 208.85.203.242
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/85215
Del: integrated -- https://master.php.net/note/delete/85215/integrated
Del: useless -- https://master.php.net/note/delete/85215/useless
Del: bad code -- https://master.php.net/note/delete/85215/bad+code
Del: spam -- https://master.php.net/note/delete/85215/spam
Del: non-english -- https://master.php.net/note/delete/85215/non-english
Del: in docs -- https://master.php.net/note/delete/85215/in+docs
Del: other reasons-- https://master.php.net/note/delete/85215
Reject -- https://master.php.net/note/reject/85215
Search -- https://master.php.net/manage/user-notes.php