Q:

Why can some PHP objects be converted to a string

I was looking into PHP tidy and I saw the following code
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
// Output
echo $tidy;

Tidy here is an object. Why isn't this throwing a Catchable fatal error: Object of class tidy could not be converted to string error???

A:

I'm not familliar with tidy, but my guess is, that the object implements the magic method __toString(), as described here: http://php.net/manual/en/language.oop5.magic.php#object.tostring

