3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeObject implements JsonSerializable { public string $placeholder = 'hallo'; public string $id; public string $model; public string $value; public bool $disabled; public bool $required; public function jsonSerialize(): mixed { return array_map( fn($value) => $value ?? '', array_merge( get_class_vars(__CLASS__), get_object_vars($this) ) ); } } class MainObject implements JsonSerializable { public string $mainName; public SomeObject $someObject; public function __construct() { $this->mainName = (new ReflectionClass(MainObject::class))->getShortName(); $this->someObject = new SomeObject(); } public function jsonSerialize(): mixed { return get_object_vars($this); } } $main = new MainObject; echo json_encode($main, JSON_PRETTY_PRINT);
Output for git.master, git.master_jit, rfc.property-hooks
{ "mainName": "MainObject", "someObject": { "placeholder": "hallo", "id": "", "model": "", "value": "", "disabled": "", "required": "" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
116.09 ms | 405 KiB | 5 Q