Question on arrays as properties
| From: | Bob Silva | Date: | Fri, 28 Oct 2005 05:09:41 +0000 |
| Subject: | Question on arrays as properties | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-19775@lists.php.net to get a copy of this message | ||
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