Autor: John Robinson Data: Dla: exim-users Temat: Re: [exim] More integer annoyances in 4.65
On 03/01/2007 17:45, Wakko Warner wrote: > David Saez Padros wrote:
>> why it's natural to think that an empty string equals to zero ? in my
>> point of view an empty or null string is not a number and if somebody
>> wants to compare numbers he should ensure that both thing to compare
>> in a *numeric comparision* are numbers.
>
> # perl -e 'print "Its 0\n" if "" == 0'
> Its 0
> #
>
> Case closed =)
Tee hee. In PHP[1], (0 == "") is true but ("" == 0) is false - the first
is a numerical comparison (taken from the LHS) and the "" is converted
to zero, but the second is a string comparison (again the type of the
comparison is taken from the LHS) and the zero converts to "0". This is
why PHP added the === operator meaning strictly equal to i.e. no casting
or conversions allowed.
Cheers,
John.
PS. Sorry for going off-topic.
[1] Even sorrier if PHP's changed since I last wrote any.