Well, OK, so you are complaining about PHP when your code isn't even aware that it is comparing integers with strings and comparing variables that have no value? On second thought you are correct in that PHP should be smart enough to realize your code has no idea what it is doing. Java would surely pick that up instantly.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Campbell Sent: Monday, January 14, 2008 11:23 AM To: NYPHP Talk Subject: Re: [nyphp-talk] Why do "cool kids" choose PHP to build websitesinstead of Java On Jan 14, 2008 8:17 AM, Kenneth Downs <[EMAIL PROTECTED]> wrote: > Elliotte Harold wrote: > > Michael Southwell wrote: > > > >> 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. > >>> > > > > > > Yes, this is what PHP does. It's just that what PHP does is insane. > > It does not match any normal, logical thought process. > > > > A content-free emotive statement. > > It would be more accurate to say that it follows a set of principles > you do not share, namely, weak typing. We would expect you as a java > dude to prefer strong typing. Strong typing to me is inappropriate in > a web layer, and reduces my productivity. Is it insane? No, just > incompatible with my design goals and methods. I am with Rusty on this one. PHP is insane in this regard. Consider the following statements: 1+1=2 if a < b and b < c then a < c if a=b and b=c then a=c I am a bit of a purist, and I hold these three rules to be self-evident and violations of these rules put one outside the realm of a normal logical thought process. PHP violates #2 and #3, therefore PHP is insane. Other weakly typed languages do not violate these rules. This is not about weak vs strong typing, although it is much easier to get basic logic right in a strongly typed language. If you still don't understand the problem, then take this quiz: what is the output of the following statements? var_dump(true + true); var_dump(null < 0); var_dump(null < -1); var_dump(null < 1); Regards, John Campbell _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.2/1224 - Release Date: 1/14/2008 5:39 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.2/1224 - Release Date: 1/14/2008 5:39 PM _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php