i am new to php and is in need of some help to understand the aspects of php objects which i do not get. In class a i have made class b and c which extends a, but what i want to do is acess the public letters variable in class a from class c so in can get ot the function testb() from class c.
Any help is much appreciated guys
<?php
class a {
public $letters;
function __construct() {
$this->letters->b = new b();
$this->letters->c = new c();
}
}
class b extends a {
function __construct() {
echo "hello world from b ";
}
private function testb() {
echo "testing from b";
}
}
class c extends a {
function __construct() {
echo "hello world from c ";
$this->letters->b->testb();
}
}
$a = new a();
?>
the following script echos our "hello world from b" and "hello world from c" but it does not print out "testing from b"...