3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace namespacename { class classname { function __construct() { echo __METHOD__,"\n"; } } function funcname() { echo __FUNCTION__,"\n"; } const constname = "namespaced"; } /////////////////////////// class classname { function __construct() { echo __METHOD__,"\n"; } } function funcname() { echo __FUNCTION__,"\n"; } const constname = "global"; $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 ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
5.4.230.0140.05412.38
5.4.220.0130.04912.38
5.4.210.0160.04412.38
5.4.200.0120.05012.39
5.4.190.0180.04312.38
5.4.180.0130.04912.38
5.4.170.0120.05112.39
5.4.160.0120.05312.38
5.4.150.0150.04312.38
5.4.140.0190.04312.07
5.4.130.0140.04612.05
5.4.120.0130.04812.01
5.4.110.0120.05012.01
5.4.100.0130.05312.01
5.4.90.0140.04612.01
5.4.80.0260.06312.01
5.4.70.0190.04612.01
5.4.60.0140.04112.01
5.4.50.0110.04212.01
5.4.40.0150.04311.99
5.4.30.0140.03811.99
5.4.20.0130.04411.99
5.4.10.0090.04311.99
5.4.00.0140.04311.48
5.3.280.0150.04712.71
5.3.270.0120.06512.72
5.3.260.0170.04712.72
5.3.250.0140.05412.72
5.3.240.0110.05112.72
5.3.230.0230.07312.71
5.3.220.0130.04612.68
5.3.210.0120.04712.68
5.3.200.0120.04212.68
5.3.190.0110.04612.67
5.3.180.0150.03912.67
5.3.170.0140.05612.67
5.3.160.0120.04212.67
5.3.150.0110.04712.67
5.3.140.0160.05012.66
5.3.130.0140.04912.65
5.3.120.0120.05012.66
5.3.110.0160.04612.66
5.3.100.0200.04812.12
5.3.90.0120.04912.09
5.3.80.0110.04512.09
5.3.70.0200.06912.09
5.3.60.0140.04612.07
5.3.50.0130.05012.02
5.3.40.0140.04512.01
5.3.30.0160.06411.97
5.3.20.0140.04411.76
5.3.10.0120.04911.72
5.3.00.0130.04611.70