Skip to content

Instantly share code, notes, and snippets.

@parap
Created April 9, 2012 08:18
Show Gist options
  • Save parap/2342272 to your computer and use it in GitHub Desktop.
Save parap/2342272 to your computer and use it in GitHub Desktop.
<?php
class A {
public function test() {
$this->abc[] = 'test';
}
}
class B extends A {
public $abc = array('pre-test');
}
$a = new A();
print_r($a);
echo'<br>';
$a->test();
print_r($a);
echo'<br>';
$b = new B();
print_r($b);
echo'<br>';
$b->test();
print_r($b);
// output is
// B Object ( [abc] => Array ( [0] => pre-test [1] => test ) )
// - property is populated properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment