[PHP-NOTES] note 130461 added to function.json-encode

[email protected] ("[email protected]") Wed, 27 Aug 2025 04:43:51 +0000
Newsgroups php.notes
Message-ID <[email protected]>
Note that json_encode() includes virtual properties in PHP 8.4 that define getters, which is unexpected.

class Foo { public int $bar { get { return 42; } } }

An instance of this will yield the following JSON: {"bar":42}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 14.202.77.42)
----
Manual Page -- https://php.net/manual/en/function.json-encode.php
Edit        -- https://main.php.net/note/edit/130461
Del: integrated  -- https://main.php.net/note/delete/130461/integrated
Del: useless     -- https://main.php.net/note/delete/130461/useless
Del: bad code    -- https://main.php.net/note/delete/130461/bad+code
Del: spam        -- https://main.php.net/note/delete/130461/spam
Del: non-english -- https://main.php.net/note/delete/130461/non-english
Del: in docs     -- https://main.php.net/note/delete/130461/in+docs
Del: other reasons-- https://main.php.net/note/delete/130461
Reject      -- https://main.php.net/note/reject/130461
Search      -- https://main.php.net/manage/user-notes.php