Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  jsonSerialize() in extended class

Since PHP 5.4.0, there is a convenient interface JsonSerializable which can be used to indicate that a PHP object can be serialized to JSON object. It has only one method which should be implemented by any class which implements this interface. The method is named jsonSerialize().It's really easy to serialize an object to JSON object. Here is one example:<?phpclass ArrayValue implements JsonSerializable { public function __construct(array $array) { $this->array = $array; } public function jsonSerialize() { return $this->array; }}$array = [1, 2, 3];echo json_e...

10,166 0       JSON INHERITANCE JSONSERIALIZE EXTENDS