class Foo {
    public function __toString()
    {
        return "Some text about the OBJECT"; 
    }
}
$foo = new Foo();
echo $foo;
__toString
method gets invoked when we echo or print the object
by Valeri Tandilashvili
4 years ago
PHP
OOP
PHP Object Oriented Programming (OOP)
2
Pro tip: use ```triple backticks around text``` to write in code fences