<?php
class A {
private $json = "{\"prop1\": 1}";
public function __toString() {
return $this->json;
}
}
$obj = new \stdClass;
$obj->prop0 = new A;
var_dump(json_encode($obj));
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9BtOc on line 8
string(12) "{"prop0":{}}"
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9BtOc on line 8
Fatal error: Call to undefined function json_encode() in /in/9BtOc on line 10
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/9BtOc on line 3
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/9BtOc on line 3
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/9BtOc on line 3
Process exited with code 255.