PHP Question: Print Object
Question
The following code was executed.
<?php
class MyClass {
private $foo = "bar";
}
$myObject = new MyClass();
echo $myObject;
Which produced the following error.
Catchable fatal error: Object of class MyClass could not be converted to string in test.php on line 7
Call Stack:
0.0011 323736 1. {main}() /test.php:0
How can the code be simply changed to prevent this error and produce some form of result?