3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); namespace { class Foo { const TEST = 'global'; } } namespace ClassConstFetchDefined { class Foo { const TEST = 'namspaced'; } class HelloWorld { public static function doFoo() { if (defined('Foo::TEST')) { echo \Foo::TEST . PHP_EOL; } else { echo 'not defined' . PHP_EOL; } if (defined('\Foo::TEST')) { echo \Foo::TEST . PHP_EOL; } else { echo 'not defined' . PHP_EOL; } if (defined('ClassConstFetchDefined\Foo::TEST')) { echo Foo::TEST . PHP_EOL;; } else { echo 'not defined' . PHP_EOL; } if (defined('\ClassConstFetchDefined\Foo::TEST')) { echo Foo::TEST . PHP_EOL; } else { echo 'not defined' . PHP_EOL; } } } (new HelloWorld)->doFoo(); }
Output for git.master, git.master_jit, rfc.property-hooks
global global namspaced namspaced

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:
82.59 ms | 405 KiB | 5 Q