Cal,
Thanks for the suggestion. I looked up equality on www.php.net, and there are many comments about how == works.
I also found out === works too, or is that still lazy?

Thanks,
Stephen

Cal Evans wrote:

Stephen,

"Friday August 22" evaluates to the number 0. (check the docs for intval())
Therefore the condition would be true.

I stated in an earlier thread this week. It is bad for to allow PHP todo
your conversions for you. At the least it's lazy, at the most it will cause
unpredictable results. (as is your case below.)

If you really MUST compare a string and a number, do an explicit cast first.

if ($a==intval("Friday August 22"))
or
if (strval($a)=="Friday August 22")

In both cases above, since we are explicitly casting, it is easy to predict
the results and explain them.

(In the above, the first should be true and the second should be false.)

=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to