Is it possible to echo
class object so it will show some property of this object?
Let's say we've got such class
class Color {
public $color = "";
function __construct($color) {
$this->color = $color;
}
}
and then we create it's instance
and echo
it:
$myColor = new Color("red");
echo $myColor; //I want it to echo 'red' ( same as I'd do echo $myColor->color )
What happens here is my object has prop color
. And when I have echo $object
I want it to really do echo $object->prop
Is it possible to make such 'echoing' handler?