<?php
class test implements JsonSerializable {
public $a = 2;
public function JsonSerialize() {
return array('test'=>array('c' => $this));
}
}
var_dump(json_encode(new test(), JSON_PARTIAL_OUTPUT_ON_ERROR));
var_dump(json_last_error_msg());
Deprecated: Return type of test::JsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/GbKSd on line 5
string(19) "{"test":{"c":null}}"
string(18) "Recursion detected"
Notice: Use of undefined constant JSON_PARTIAL_OUTPUT_ON_ERROR - assumed 'JSON_PARTIAL_OUTPUT_ON_ERROR' in /in/GbKSd on line 10
Warning: json_encode() expects parameter 2 to be long, string given in /in/GbKSd on line 10
NULL
Fatal error: Call to undefined function json_last_error_msg() in /in/GbKSd on line 11
Process exited with code 255.