<p>How do I extend my parent's options array for child classes in PHP?</p>

<p>I have something like this:</p>

<pre><code>class ParentClass {

     public $options = array(
          'option1'=&gt;'setting1'
     );

     //The rest of the functions would follow
}
</code></pre>

<p>I would like to append to that options array in a child class without erasing any of the parent options. I've tried doing something like this, but haven't quite got it to work yet:</p>

<pre><code>class ChildClass extends ParentClass {

     public $options = parent::options + array(
          'option2'=&gt;'setting2'
     );

     //The rest of the functions would follow
}
</code></pre>

<p>What would be the best way to do something like this?</p>

I think it is better practice to initialize this property in the constructor and then you can extend the value in any descendant class:
```
```
<?php
class ParentClass {

    public $options;
    public function __construct() {
        $this->options = array(
            'option1'=>'setting1'
        );
    }
    //The rest of the functions would follow
}

class ChildClass extends ParentClass {
    public function __construct() {
        parent::__construct();
        $this->options['option2'] = 'setting2';
    }
    //The rest of the functions would follow
}
?>
```
```