I have a class hierarchy in PHP 5.2.9 .
The base class has a protected property, which is an associative array.
Children's classes can add some elements to the array.
Children's classes are declared in separate files (plugins), which will be created and added by several developers.
What is the best way to add elements to a property in child classes so that declaring a new child is as simple as possible?
<?php class A { protected $myproperty = array ( 'A1' => 1, 'A2' => 2 ); function myprint() { print_r($this->myproperty); } }; class B extends A {
Ideally, I would like to do this for developers as simple as declaring a variable or private property without having to copy paste any code.
source share