Re: Zero is equal to any string?

From: Date: Sun, 03 Sep 2000 08:33:42 +0000
Subject: Re: Zero is equal to any string?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14970@lists.php.net to get a copy of this message
From: "Lars Torben Wilson" <torben@pinc.com> > Anyway, the upshot is that in the test above, the string is being > converted into an integer for the comparison. Since a string converted > into an integer is evaluated as equivalent of all the digit characters > of the string before the first non-digit character, and since there > are no digits before the first non-digit, the resulting int is '0'. From: <php3@developersdesk.com> > Feature. > > Any string when evaluated in a numeric context has a value of 0. Thanks, it does make perfect sense now. :) > NOTE: === is php4 only. If you are not yet using php 4, you should > seriously consider it now. I've been lurking on the developers list > and belive 4.0.2 to be the best debugged version of PHP ever! Yes, I am using 4.0.2. I realise that the === operator matches variable type as well. I have been using === in the page ever since finding that == didn't work, so I'll just have to keep an eye out for this situation in the future. ;) Cheers, Simon Garner.

« previous php.general (#14970) next »