RE: [PHP] = 0 and = "0"
| From: | Matthew Loff | Date: | Thu, 25 Oct 2001 08:28:55 +0000 |
| Subject: | RE: [PHP] = 0 and = "0" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72211@lists.php.net to get a copy of this message | ||
The only reason I could see that not working is if PHP is typecasting
"test" to (int) in the second example...
$qty = "0"; (string)
"test" = "test"; (string)
"0" != "test" (evaluates true)
$qty = 0; (int)
"test" = 0; (when cast to int)
0 != 0 (evaluates false)
e.g. By comparing an int to a string in the 2nd example, the string is
casted to int, and the int cast of "test" is 0.
-----Original Message-----
From: Robin Chen [mailto:robinche@vividnet.com]
Sent: Thursday, October 25, 2001 4:06 AM
To: php-general@lists.php.net
Subject: [PHP] = 0 and = "0"
why does
<? $qty = "0" ; if ($qty != "test") print "qty is not test"; ?>
work properly but not the following
<? $qty = 0 ; if ($qty != "test") print "qty is not test"; ?>
Thanks,
Robin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net