I have this code:
class one{
public $instance;
function instance(){
$this->instance = 'instance was created';
}
function execute(){
$this->instance .= "and something happened";
}
}
$class = new one;
$class->instance();
$class->execute();
echo $class->instance;
And it does what i expect it to do, but how can i chain actions, for example how could i call these functions in one line:
$class->instance()->execute();
And i know it's possible to do it like this:
one::instance()->execute();
but in this case i would need to have static functions which makes things complicated, i need some explanation on these things