3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ClassPHP74 { private string $field; public function __construct(string $field) { $this->field = $field; } public function getField(): string { return $this->field; } } class ClassPHP81 { public function __construct(public readonly string $field) {} } $php74 = new ClassPHP74('coucou'); var_dump($php74->getField()); var_dump($php74->__construct('hello')); var_dump($php74->getField()); $php81 = new ClassPHP81('coucou'); var_dump($php81->field); var_dump($php81->__construct('hello')); var_dump($php81->field);
Output for git.master, git.master_jit
string(6) "coucou" NULL string(5) "hello" string(6) "coucou" Fatal error: Uncaught Error: Cannot modify readonly property ClassPHP81::$field in /in/mWvLX:20 Stack trace: #0 /in/mWvLX(31): ClassPHP81->__construct('hello') #1 {main} thrown in /in/mWvLX on line 20
Process exited with code 255.
Output for rfc.literals, rfc.partials, rfc.enumerations
Parse error: syntax error, unexpected identifier "string", expecting variable in /in/mWvLX on line 20
Process exited with code 255.

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:
16.8 ms | 456 KiB | 5 Q