What, if anything, is the minimum change (fewest inserted/deleted/modified characters) required to make the output The result is bar
:
<?php
class A {
private $foo = "bar";
public function __toString() {
return $this->foo;
}
}
$myObject = new A();
echo "The result is " . $myObject;
?>
Was this specific for a particular PHP version? Because no modifications would already produce the desired output in PHP5
Comment by AlexPHP — July 22, 2010 @ 12:49 pm
Must have been PHP 4, and must have had something to do with the way that objects were evaluated for concatenation rather than separately. If I had PHP 4 installed, I’d try it.
Comment by snoyes — July 22, 2010 @ 1:52 pm