> > > 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.?
According to my experience I'd say both, depending on the context...
If you have to determin its type before using a variable and then, when
changing it, have to do an explicit typecast, programming gets "cleaner"
and in many cases more safe.
On the other hand, if let's say false == 0 and true == 1, you can do
nice things like arithmetic operations using booleans:
$x = $y * (-1 * (abs($z) == $z));
Get the idea?
> 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?
AFAIK it's only a matter of speed. Unary operators consume less
time than binary ones... Correct me if I'm wrong.
> Are you coming to Ottawa in the future?
This I don't know... ;)
It's not a bug, it's a feature.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]