3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Hoge { const CONST_FOO = 'foo'; public function __construct() { // 定数が存在する場合 print constant('self::CONST_FOO') . PHP_EOL; // PHP8以降では定数が存在しない場合は例外が送出される try { print constant('self::NOT_EXIST'); } catch (Error $e) { print $e->getMessage(); print $e->getTraceAsString(); } } } $obj = new Hoge();
Output for git.master, git.master_jit, rfc.property-hooks
foo Undefined constant self::NOT_EXIST#0 /in/tbFJR(14): constant('self::NOT_EXIST') #1 /in/tbFJR(22): Hoge->__construct() #2 {main}

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:
30.71 ms | 401 KiB | 8 Q