Trying to learn OO PHP but I'm confused on something. I've used frameworks before where they linked together the -> to call multiple functions or variables within those functions.
ex. $variable = $this->query($stmt)->result()->name;
How would you go about setting this up?
class test{
public $name;
public function __construct(){
$this->name = 'Jon'; // pretending that Jon is a db call result
}
public function change_name($n){
$this->name = $n;
}
public function get_name(){
return $this->name;
}
}
$i = new test();
how would I do this? Or is this totally just not possible.
$i->change_name('george')->get_name; // as an example