Spiga

Why Should PHP ever be taught in school?

This posting by Ka-Ping Yee on why PHP should never be taught is precisely why PHP should be taught. If something is popular but hard to understand then we need an education process. To just shake our heads and give up is simply immature (or trolling). Otherwise we might as well say that English (or any other spoken language for that matter) should not be taught, because spoken languages are illogical, imprecise and therefore ... useless :)

Most programming languages have similar gotchas. Oracle's PL/SQL has "" being equivalent to null. Javascript believes that 0 and "" are equivalent. C has non-zero being equivalent to boolean true. Lisp's gotcha begins with ( and ends with ) -- (just a joke). Java's gotcha begins with J2EE and the obsolete baggage that comes with it.

PS: The confusion is because === is the real equality operator and should be used here. In PHP, == is equality after typecasting, where 0 == "0" and "" == "0" evaluating to true are accepted conventions. They are useful constructs in many situations in a similar vein to C's convention of 0 being boolean true and non-zero being boolean false, which the critics cleverly ignore. See the PHP Manual on type comparisons

0 comments: