Within my code, I have two classes- the first "Foo" initiates the second "Bar"... what I want to do is find some method of using the functions and variables from the parent.
class Bar {
function __construct() {
/*
* From within this function, how do I access either the returnName() function
* OR the $this -> name variable from the class above this?
* The result being:
*/
$this -> name = parent::returnName();
$this -> else = parent -> name;
}
}
class Foo {
function __construct() {
$this -> name = 'Fred';
$this -> var = new Bar();
}
function returnName() {
return $this -> name;
}
}
$salad = new Foo();
I realise the syntax of "parent" refers to either an implement or extends, but is it possible to use this kind of method?