$hair = new Hair();
$hair->colour = 'brown';
You can do this without pre-defining any properties.
The above is a much less wordy way of doing the following:
No, it is not the same. You can override what happens when you do setColor - like send notification to some other object or set also matching color for the shoes, etc. :) but you can't have any behavior attached to setting value.
This is a feature of a dynamic language, not a flaw in my argument. And
Not having rigid definitions of properties is also a feature of dynamic language ;)
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com