How to get variable from one class to another?
<p>I am a newbie to PHP and have question which writen in Example_02 class.</p>

<pre><code>&lt;?php

class Entity 
{ 

    private $components = array(); 

    public function add_component(Component $component) 
    { 
        if (in_array($component, $this-&gt;components) == false) 
            $this-&gt;components[] = $component; 
    } 

    public function get_component(Component $component) 
    { 
        if (in_array($component, $this-&gt;components) == true) 
            return $this-&gt;components[array_search($component, $this-&gt;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-&gt;add_component(new Example_01()); 
$ent-&gt;add_component(new Example_02()); 

var_dump($ent); 

?&gt;
</code></pre>
