I have a class which is instantiated globally and in turn instantiates a second class from within its constructor. What I can't figure out is how to gain access to properties of the first class from the second.
<?php
class Foo
{
public $bar;
public $myProperty;
public function __construct()
{
$this->bar = new Bar();
$this->myProperty='hello';
}
}
class Bar
{
public function __construct()
{
echo $foo->myProperty; //I can't see that from here
}
}
$foo = new Foo();
?>
what might be the correct way of going about this?