<?php
class y { private $ppp = 123; public function __toString() { return 123; } }
class x
{
public function __construct()
{
$x =& $this;
$x = new y;
echo $this;
}
}
new x;
Fatal error: Uncaught Error: Object of class x could not be converted to string in /in/26rnD:9
Stack trace:
#0 /in/26rnD(12): x->__construct()
#1 {main}
thrown in /in/26rnD on line 9
Process exited with code 255.
Catchable fatal error: Method y::__toString() must return a string value in /in/26rnD on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Method y::__toString() must return a string value in /in/26rnD on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/26rnD on line 2
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/26rnD on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/26rnD on line 2
Process exited with code 255.