mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

According to https://www.php.net/manual/en/class.domdocument: When using json_encode() on a DOMDocument object the result will be that of encoding an empty object. But this was broken in 8.1. The output was `{"config": null}`. That's because the config property is defined with a default value of NULL, hence it was included. The other properties are not included because they don't have a default property, and nothing is ever written to their backing field. Hence, the JSON encoder excludes them. Similarly, `(array) $doc` would yield the same `config` key in the array. Closes GH-11840.
11 lines
136 B
PHP
11 lines
136 B
PHP
--TEST--
|
|
JSON encoding a DOMDocument
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
$doc = new DOMDocument;
|
|
echo json_encode($doc);
|
|
?>
|
|
--EXPECT--
|
|
{}
|