mirror of
https://github.com/php/php-src.git
synced 2026-04-21 23:18:13 +02:00
4662151ea7
json_encode() no longer throws warnings. Instead only the error code for json_last_error() is set. As it is hard to debug the error from just an error code an optional $as_string parameter was added to json_last_error(), which returns an error message instead of an error code.
41 lines
626 B
PHP
41 lines
626 B
PHP
--TEST--
|
|
json_encode() & endless loop - 2
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("json")) print "skip"; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$a = new stdclass;
|
|
$a->prop = $a;
|
|
|
|
var_dump($a);
|
|
|
|
echo "\n";
|
|
|
|
var_dump(json_encode($a));
|
|
var_dump(json_last_error());
|
|
var_dump(json_last_error(true));
|
|
|
|
echo "\n";
|
|
|
|
var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR));
|
|
var_dump(json_last_error());
|
|
var_dump(json_last_error(true));
|
|
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECTF--
|
|
object(stdClass)#%d (1) {
|
|
["prop"]=>
|
|
*RECURSION*
|
|
}
|
|
|
|
bool(false)
|
|
int(6)
|
|
string(%d) "Recursion detected"
|
|
|
|
string(22) "{"prop":{"prop":null}}"
|
|
int(6)
|
|
string(%d) "Recursion detected"
|
|
Done
|