PHP: a fractal of not so bad design


16-05-2012 00:00 - Zdroj: php.vrana.cz
Whether you like PHP or not, go and read the article PHP: a fractal of bad design. It's well written by someone who really knows the language which is not true for most other articles about this topic. And there are numerous facts why PHP is badly designed on many levels. There is almost no FUD so it is also a great source for someone who wants to learn PHP really well (which is kind of sad). I am surprised that I am able to live with PHP and even like it. Maybe I am badly designed too so that I am compatible with PHP. I was able to circumvent or mitigate most problems so the language doesn't bother me. Anyway, there are several topics which are inaccurate or I don't agree with them. Here they are with no context so they probably wouldn't make much sense without reading the original article: === compares values and type… except with objects, where === is only true if both operands are actually the same object! For objects, == compares both value (of every attribute) and type, which is what === does for every other type. This makes sense to me for two reasons: It is sometimes useful to know if two objects are the same and reusing === for this operations looks like a good idea to me. Comparing properties of two objects with different class is not very useful anyway. Internally, $a = new stdClass stores something like “object ID 576ab4” into the variable $a. $b = new stdClass stores a different object ID. So these two objects are not identical even if they are of the same class and have the same properties. Contrary, $c = $a stores the same object ID to $c so it is identical to $a. Global variables need a global declaration before they can be used. This is a natural consequence of the above, so it would be perfectly reasonable, except that globals can’t even be read without an explicit declaration—PHP will quietly create a local with the same name, instead. I’m not aware of another language with similar scoping issues. This is one ... - Pokračovat...
addthis





Poslední příspěvky z blogu:
php.vrana.cz



Zašlete svůj blog
Požadavky na Blog
Ochrana osobních údajů
Kontakty

This site uses Thumbshots previews