Question on arrays as properties

php.internals

Bob Silva

20 years ago
Hi, Am I correct in saying that a class property cannot be initialized to an array? Looking at zend_declare_property it clearly states that Internal zvals cant be arrays. So how would I go about creating the following inherited property in all my subclasses if my core class has this property? class ZObject { protected $_props = array(); . } class ZString { public function __construct() { $this->setProperty($name, $value) } public function setProperty($name, $value) { $this->_props['value']; } } In other words, how would I create a property that is an array (in C) where that property is available to all my subclasses WITHOUT initializing it manually in the __construct, which would force each subclass constructor to call its parent (while good design, I'd prefer not to have this constraint). Thanks Bob Silva

Michael Wallner

20 years ago
Hi Bob Silva, you wrote:
> Hi, In other words, how would I create a property that is an array > (in C) where that property is available to all my subclasses WITHOUT > initializing it manually in the __construct, which would force each > subclass constructor to call its parent (while good design, I'd > prefer not to have this constraint).
No (really) other way. Regards,
-- Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz