I am a newbie to PHP and have question which writen in Example_02 class.
<?php
class Entity
{
private $components = array();
public function add_component(Component $component)
{
if (in_array($component, $this->components) == false)
$this->components[] = $component;
}
public function get_component(Component $component)
{
if (in_array($component, $this->components) == true)
return $this->components[array_search($component, $this->components)];
}
}
class Component
{
}
class Example_01 extends Component
{
public $example_var;
public function __construct()
{
}
}
class Example_02 extends Component
{
public function __construct()
{
// how to get $example_var from Example_01 class?
}
}
$ent = new Entity();
$ent->add_component(new Example_01());
$ent->add_component(new Example_02());
var_dump($ent);
?>
An example of 3 classes interlinked together through a base class. Hope im not too wrong. :-s