note 85274 added to function.empty
| From: | justin at booleangate dot org | Date: | Sat, 23 Aug 2008 00:09:32 +0000 |
| Subject: | note 85274 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143762@lists.php.net to get a copy of this message | ||
@john_jian, et al
PHP does have explicit type casting.
Also consider that, due to the implicit casting that Anonymous pointed out, "-" ==
(int)"-" and "+" == (int)"-" both evaluate as bool(true).
var_dump("-" == (int)"-");
var_dump("+" == (int)"-");
This is small hiccup that I ran into a few weeks back when validating some user input. I thought it
was a bug at first, but it's not, it's just one of those gotchas that crop up sometimes
when dealing with a typeless language.
It would be preferable, however, if PHP could raise an E_NOTICE when it encounters a cast that
results in a default value such as in the above case.
----
Server IP: 208.69.120.35
Probable Submitter: 66.215.165.244
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/85274
Del: integrated -- https://master.php.net/note/delete/85274/integrated
Del: useless -- https://master.php.net/note/delete/85274/useless
Del: bad code -- https://master.php.net/note/delete/85274/bad+code
Del: spam -- https://master.php.net/note/delete/85274/spam
Del: non-english -- https://master.php.net/note/delete/85274/non-english
Del: in docs -- https://master.php.net/note/delete/85274/in+docs
Del: other reasons-- https://master.php.net/note/delete/85274
Reject -- https://master.php.net/note/reject/85274
Search -- https://master.php.net/manage/user-notes.php