note 129811 added to function.json-last-error
| From: | greaties@ghvernuft.nl | Date: | Sat, 19 Oct 2024 23:01:23 +0000 |
| Subject: | note 129811 added to function.json-last-error | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221600@lists.php.net to get a copy of this message | ||
Protected and private properties are ignored,
when json_encoding a class instance.
The snippet
<?php
class Example
{
private $privateprop = "private property";
protected $protectedprop = "protected property";
public $publicprop = "public property";
}
echo json_encode(new Example);
?>
only returns
{"publicprop":"public property"}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 217.100.185.202)
----
Manual Page -- https://php.net/manual/en/function.json-last-error.php
Edit -- https://main.php.net/note/edit/129811
Del: integrated -- https://main.php.net/note/delete/129811/integrated
Del: useless -- https://main.php.net/note/delete/129811/useless
Del: bad code -- https://main.php.net/note/delete/129811/bad+code
Del: spam -- https://main.php.net/note/delete/129811/spam
Del: non-english -- https://main.php.net/note/delete/129811/non-english
Del: in docs -- https://main.php.net/note/delete/129811/in+docs
Del: other reasons-- https://main.php.net/note/delete/129811
Reject -- https://main.php.net/note/reject/129811
Search -- https://main.php.net/manage/user-notes.php