class - OOP PHP: Using parent's static element in declaration of child static element? -
i'm trying write class uses parent's static declared array add new value to. below kind of feel of how i'm trying run it...
class superclass { protected static $array_name = array('value1'); } class subclass extends superclass { protected static $array_name = array_push(parent::$array_name, 'value2'); }
is there way implement without __construct() function?
i'm trying implement static working model superclass , parents...
i'm not entirely sure if want static classes completely, want give or take :
<?php class superclass { static $array_name = array('value1'); } class subclass extends superclass { static $array_name = 'foo'; function __construct(){ self::$array_name = array_push(parent::$array_name, 'value2'); } } $foo = new subclass(); var_dump($foo::$array_name); // prints int 2 - push returns number of elements in array. ?>
Comments
Post a Comment