3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements \JsonSerializable { 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->c, $this->b]; } } $t = new Test(); echo json_encode($t->jsonSerialize()); echo json_encode($t);

preferences:
31.37 ms | 402 KiB | 5 Q