note 87919 added to function.define
| From: | counterpoint at aliro dot org | Date: | Tue, 30 Dec 2008 18:04:20 +0000 |
| Subject: | note 87919 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148686@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 92.48.74.199
Probable Submitter: 86.143.92.138
----
Manual Page -- http://www.php.net/manual/en/function.define.php
Edit -- https://master.php.net/note/edit/87919
Del: integrated -- https://master.php.net/note/delete/87919/integrated
Del: useless -- https://master.php.net/note/delete/87919/useless
Del: bad code -- https://master.php.net/note/delete/87919/bad+code
Del: spam -- https://master.php.net/note/delete/87919/spam
Del: non-english -- https://master.php.net/note/delete/87919/non-english
Del: in docs -- https://master.php.net/note/delete/87919/in+docs
Del: other reasons-- https://master.php.net/note/delete/87919
Reject -- https://master.php.net/note/reject/87919
Search -- https://master.php.net/manage/user-notes.php