3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace namespacename; class classname { function __construct() { echo __METHOD__,"\n"; } } function funcname() { echo __FUNCTION__,"\n"; } const constname = "namespaced"; include 'example1.php'; $a = 'classname'; $obj = new $a; // prints classname::__construct $b = 'funcname'; $b(); // prints funcname echo constant('constname'), "\n"; // prints global /* note that if using double quotes, "\\namespacename\\classname" must be used */ $a = '\namespacename\classname'; $obj = new $a; // prints namespacename\classname::__construct $a = 'namespacename\classname'; $obj = new $a; // also prints namespacename\classname::__construct $b = 'namespacename\funcname'; $b(); // prints namespacename\funcname $b = '\namespacename\funcname'; $b(); // also prints namespacename\funcname echo constant('\namespacename\constname'), "\n"; // prints namespaced echo constant('namespacename\constname'), "\n"; // also prints namespaced ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: include(): open_basedir restriction in effect. File(example1.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/l3k6F on line 16 Warning: include(example1.php): Failed to open stream: Operation not permitted in /in/l3k6F on line 16 Warning: include(): Failed opening 'example1.php' for inclusion (include_path='.:') in /in/l3k6F on line 16 Fatal error: Uncaught Error: Class "classname" not found in /in/l3k6F:19 Stack trace: #0 {main} thrown in /in/l3k6F on line 19
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:
64.93 ms | 401 KiB | 8 Q