[SR-Users] how can string "0" be equal to int 0?
Iñaki Baz Castillo
ibc at aliax.net
Fri Oct 15 13:07:57 CEST 2010
2010/10/15 Andrei Pelinescu-Onciul <andrei at iptel.org>:
> Because "==" works only with arguments of the same type, 0 it's
> autoconverted to "0". The alternative would be to log an error.
>
> Here are the rules for ==:
> /* if left is string, eval left & right as string and use string diff.
> * if left is int eval as int using int diff
> * if left is undef, look at right and convert to right type
> */
Hi, IMHO it's important not to "imitate" unexpected comparissions as
they occur in the "great" PHP language:
http://www.otton.org/2008/08/06/stupid-php-tricks-true-false-comparison/
--
Iñaki Baz Castillo
<ibc at aliax.net>
More information about the sr-users
mailing list