note 88112 added to function.define
| From: | Qwayzer at osu1 dot php dot net | Date: | Sun, 11 Jan 2009 07:34:12 +0000 |
| Subject: | note 88112 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149050@lists.php.net to get a copy of this message | ||
@mittiprovence
That is not related to define(). What is puzzling you is loose comparison in PHP.
"Comparing a defined constant with an int always returns true."
Well, this defined constant will return false if replaced into your example:
define('myDefinedName', 42);
By comparing an integer to a (constant) string, PHP will type cast your string to int before
comparing it to the first int. If you did not want this, you should have used the strict comparison
operator (===).
Your constant's value when cast to an integer (int)'stephane' will be equal to 0. So
($name == myDefinedName) evaluates to true.
Hope this helps.
----
Server IP: 209.41.74.194
Probable Submitter: 66.171.107.207
----
Manual Page -- http://www.php.net/manual/en/function.define.php
Edit -- https://master.php.net/note/edit/88112
Del: integrated -- https://master.php.net/note/delete/88112/integrated
Del: useless -- https://master.php.net/note/delete/88112/useless
Del: bad code -- https://master.php.net/note/delete/88112/bad+code
Del: spam -- https://master.php.net/note/delete/88112/spam
Del: non-english -- https://master.php.net/note/delete/88112/non-english
Del: in docs -- https://master.php.net/note/delete/88112/in+docs
Del: other reasons-- https://master.php.net/note/delete/88112
Reject -- https://master.php.net/note/reject/88112
Search -- https://master.php.net/manage/user-notes.php