Re: = 0 and = "0"

From: Date: Thu, 25 Oct 2001 13:05:35 +0000
Subject: Re: = 0 and = "0"
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-72263@lists.php.net to get a copy of this message
"Rasmus Lerdorf" <rasmus@php.net> wrote in message news:Pine.LNX.4.33.0110250159540.25039-100000@rasmus.php.net... > > The integer 0 is equal to False, but not Null. > > Not quite true. 0 evaluates to false. They are not equal. Try this: [...] > So be careful and try to think of 0 and false as distinct and separate > entities and you will avoid coding mistakes like this. Is this seen as a strength or a weakness of PHP.? In C(++), direct comparisons to true/false are discouraged. In other words, instead of this: bool x; if(x==true) ... if(x==false) ... itt's always considered better to do this: if(x) ... if(!x) ... But PHP seems to require a direct comparison with false in certain situations. Are there any cases where you need to do a direct comparison with true? Are you coming to Ottawa in the future? -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here

« previous php.general (#72263) next »