3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements \JsonSerializabe { protected $a; protected $b; public $c; public function __construct() { $this->a = 1; $this->b = 2; $this->c = 3; } public function jsonSerialize() { return [$this->a, $this->b]; } } $t = new Test(); echo $t->jsonSerialize(); echo json_encode($t);

preferences:
38.43 ms | 402 KiB | 5 Q