I am working in PHP object orientated.
And I am trying to chain a few method together and getting the following error
"Catchable fatal error: Object of class Try2 could not be converted to string"
What am I doing wrong?
indent preformatted text by 4 spaces
<?php
class Try2{
public $temp;
function one(){
$this->temp = 1;
return $this;
}
function two(){
$this->temp += 1;
return $this;
}
function there(){
$this->temp += 1;
return $this;
}
}
$try2 = new Try2();
echo $try2->one()->two()->there();