note 87625 deleted from function.define by torben

From: Date: Fri, 18 Sep 2009 07:42:33 +0000
Subject: note 87625 deleted from function.define by torben
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160819@lists.php.net to get a copy of this message
Note Submitter: mittiprovence at yahoo dot se ---- I'm running PHP Version 5.2.5 under Linux. And I just found out about something puzzling with the define() statement. Comparing a defined constant with an int always returns true. Here is the example code: <?php define('myDefinedName', 'stephane'); $myConstantName = myDefinedName; //$name = "0"; // Behaves as expected $name = 0; // Behaves contrary to expectation print("<br>myConstantName $myConstantName"); print("<br>name $name"); if ($name == myDefinedName) { print("<br>My name $name is (but should not be) equal to my defined name " . myDefinedName); } if ($name == $myConstantName) { print("<br>My name $name is (but should not be) equal to my constant name " . myConstantName); } ?>

« previous php.notes (#160819) next »