I am currently working on my PHP skills and at the moment I'm working with classes. What I want to do is to create a class for which I can echo the object. I have the following example:
class good_stuff {
public function __construct() {
return "This is a function called by a construct from a class called: " .__CLASS__;
}
public function __toString() {
return $this->self::__construct;
}
}
$my_object = new good_stuff();
echo $my_object;
I guess that my __toString is returning a wrong value, but I would like to know some details as $this doesn't seem properly documented. Is the only possible solution to this issue to define a property inside good_stuff and then assign and return it via __toString?
What I want to know is more information and a brief explanation of how $this works and what I'm missing from a theoretical point of view.