Skip to content

Instantly share code, notes, and snippets.

@andriasang
Created August 7, 2012 07:00
Show Gist options
  • Save andriasang/3282564 to your computer and use it in GitHub Desktop.
Save andriasang/3282564 to your computer and use it in GitHub Desktop.
class MyClass extends Configurable {
protected static $_defaults = array (
"option1" => "blah blah blah",
"option2" => 35,
"option3" => true
);
public function __construct($param, $options = null)
{
parent::__construct($options);
// do whatever else you want to do in the constructor here
//
}
public function test() {
print_r ($this->getOptions());
}
}
class MySubClass extends MyClass {
protected static $_defaults = array (
"option2" => 7453,
"option4" => "Yes we can!"
);
}
$myClass = new MyClass("I am a param", Array ("option2" => 542));
$mySubClass = new MySubClass("I am a param", Array ("option1" => "la la la la la"));
$myClass->test();
// Array ( [option1] => blah blah blah [option2] => 542 [option3] => 1 )
$mySubClass->test();
// Array ( [option1] => la la la la la [option2] => 7453 [option3] => 1 [option4] => Yes we can! )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment