note 88112 deleted from function.define by danbrown
| From: | danbrown@php.net | Date: | Sun, 11 Jan 2009 07:36:54 +0000 |
| Subject: | note 88112 deleted from function.define by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149051@lists.php.net to get a copy of this message | ||
Note Submitter: Qwayzer
----
@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.