3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Constants { public function __get($constName) { // Null for non-defined "constants" $val = null; switch($constName){ case 'FOO': $val = 'MY CONSTANT UNCHANGEABLE VALUE'; break; case 'BAR': $val = 'MY OTHER CONSTANT VALUE'; break; } return $val; } public function __set($key, $value) { throw new Exception('A runtime modification of constant values is not allowed.'); } } $c = new Constants; echo $c->FOO; $c->FOO = 'Hello World';
Output for git.master, git.master_jit, rfc.property-hooks
MY CONSTANT UNCHANGEABLE VALUE Fatal error: Uncaught Exception: A runtime modification of constant values is not allowed. in /in/UgEEm:23 Stack trace: #0 /in/UgEEm(29): Constants->__set('FOO', 'Hello World') #1 {main} thrown in /in/UgEEm on line 23
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:
47.21 ms | 401 KiB | 8 Q