Hi!

the rest of the industry, it is very confusing for programmers coming from
other languages to learn PHP.  A good example is how "==" works
differently in PHP than in other languages.  In PHP, "===" works like "=="
does everywhere else.  "(string)'0' == (int)0", for example is true in

Not everywhere. Perl has the same rules, for example.

explain === to them.  This is because PHP goes against the defacto
standard.  Maybe it would have been better if == and === had the opposite
meaning, as to not squash the standard?

There's no such standard. PHP works differently than the language you knew before, that's it. If it worked the same, it would be the same language.

Because properties are only meant to be a pretty syntax for a get/set
method.  Thats it!  I don't know of any other special behaviour in any
other language that lets you "hide" properties or anything else like that.

If that's it, we probably don't need them. They would just hide what happens in the code and confuse the user, which would not know what $a->foo means - would it work according to class attribute rules or class method rules? I think, however, this syntax might be useful - for example, Zend Framework does a lot of property/method linking, some other frameworks do that too, and individual methods might be better than catch-all in this case. But that requires consistency.

In PHP, of course, class properties are dynamic, so you can add and delete them at will. It is a standard feature of dynamic languages. For a person coming from strict compiled language like C# it might be unusual, but that's how dynamic languages work.

You make a good point.  If we can't unset a property, than we lose
consistency with regular variables which I guess ruins the point of
properties.

It doesn't have to - if we can find a consistent concept of how to do it. But we need to think about it.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to