3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum MyEnum: string { case FOO = 'FOO'; } enum MyEnumWithJson: string implements \JsonSerializable { case FOO = 'FOO'; public function jsonSerialize(): mixed { return $this->value . '[jsonSerialize]'; } } $myEnum = MyEnum::FOO; echo json_encode($myEnum); var_dump([ 'isObject' => is_object($myEnum), 'isJsonSerializable' => $myEnum instanceof JsonSerializable, ]); echo "\n"; $myEnumWithJson = MyEnumWithJson::FOO; echo json_encode($myEnumWithJson); var_dump([ 'isObject' => is_object($myEnumWithJson), 'isJsonSerializable' => $myEnumWithJson instanceof JsonSerializable, ]);
Output for git.master_jit, git.master
"FOO"array(2) { ["isObject"]=> bool(true) ["isJsonSerializable"]=> bool(false) } "FOO[jsonSerialize]"array(2) { ["isObject"]=> bool(true) ["isJsonSerializable"]=> bool(true) }

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:
37.48 ms | 717 KiB | 4 Q