note 87919 rejected from function.define by thiago
| From: | thiago@php.net | Date: | Tue, 30 Dec 2008 18:06:11 +0000 |
| Subject: | note 87919 rejected from function.define by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148687@lists.php.net to get a copy of this message | ||
Note Submitter: counterpoint at aliro dot org
----
It is not right that comparing a define with an integer always returns true. It is correct to state
that comparing zero against a define that is alphabetic will result in true - because in this case
the define is a string which will be coerced to being an integer, and if it contains nothing but
letters and spaces, the result of the coercion will be zero. Note that changing the code shown
below to use the integer 1 results in the comparison failing - only zero will compare equal and this
is correct. Similarly, changing the code below so that the name is '1stephane' (which
when coerced to integer is 1) also results in the comparison failing, again correctly. PHP is
obliging but sometimes confusing!