[nycphp-talk] Why do "cool kids" choose PHP to build websites instead of Java
Michael Southwell
michael.southwell at nyphp.com
Wed Jan 2 19:22:30 EST 2008
Elliotte Rusty Harold wrote:
> Jake McGraw wrote:
>> Tim:
>>
>> You're not to fault, and the point about Java collections Vs array()
>> is pretty good, unfortunately, I never made it that far because I was
>> completely turned off by the "article", the exact text Tim was
>> referring to:
>>
>> James Anderson wrote: The really simple answer is that after the
>> release of php 5, php became the better language.
>
> Oh really? From http://zestyping.livejournal.com/124503.html
>
>
> % cat equality.php
> <?php
>
> $a = 0;
> $b = "eggs";
> $c = "spam";
>
> print ($a == $b) ? "a == b\n" : "a != b\n";
> print ($b == $c) ? "b == c\n" : "b != c\n";
> print ($a == $c) ? "a == c\n" : "a != c\n";
> print ($a == $d) ? "a == d\n" : "a != d\n";
> print ($b == $d) ? "b == d\n" : "b != d\n";
> print ($c == $d) ? "c == d\n" : "c != d\n";
>
> ?>
>
> % php equality.php
> a == b
> b != c
> a == c
> a == d
> b != d
> c != d
>
> (Of course, starting in version 5, Java began to mess up simple
> Aristotelian logic too, but not quite this badly.)
ah, no, these answers are exactly right, given that $a is an integer, $b
and $c are strings, and $d is unset. $b and $c when converted to
integers for the purpose of comparison in #1 and #3 turn into 0 (zero)
so the comparisons are true. #2 compares two different strings and so is
false. #4 compares 0 to the integer of unset and so is true. #5 and #6
compare strings to the string of unset and so are false.
>
>
--
=================
Michael Southwell
Vice President, Education
NYPHP TRAINING: http://nyphp.com/Training/Indepth
More information about the talk
mailing list