3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(php_uname('s')); $base_dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR; file_put_contents($base_dir . 'Baz.php', "<?php namespace Foo\Bar; class BAZ {}"); file_put_contents($base_dir . 'Buz.php', "<?php namespace Foo\Bar; class Buz {}"); spl_autoload_register(function ($class) { echo "Trying to autoload $class\n"; // project-specific namespace prefix $prefix = 'Foo\\Bar\\'; // base directory for the namespace prefix global $base_dir; # = __DIR__ . '/src/'; // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { // no, move to the next registered autoloader return; } // get the relative class name $relative_class = substr($class, $len); // replace the namespace prefix with the base directory, replace namespace // separators with directory separators in the relative class name, append // with .php $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; // if the file exists, require it if (file_exists($file)) { require $file; } else { echo "Could not require $file\n"; } }); // This works as expected because the class name matches the intended // case in the file and as it is represented on disk. $c1 = new \Foo\Bar\Baz(); // This works because PHP is PHP. This is not even going to hit the // PSR-4 autoloader. The *usage* of this classname by the user is not // PSR-4 compliant but that does not make the *autoloader* noncompliant. $c2 = new \Foo\Bar\BAZ(); var_dump($c1 == $c2); // This is going to be rejected by the PSR-4 autoloader implementation. // That is fine *and expected* because the *usage* of the classname by // the user is incorrect. // // On some platforms this may actually work but that is a byproduct of // certain platforms not caring about case. But again, the *usage* of // this classname *in this context* is not PSR-4 compliant. // // PSR-4 says that case is important and that case MUST be taken into // account when creating the file path representing the class name. It // also dictates that case MUST be taken into account when you create // files on disk for the FQCN in question. // // If the FQCN is \Foo\Bar\Baz in src/Baz.php, then specifying the class // with any other case than \Foo\Bar\Baz by the user is not compliant // with PSR-4. // // In some cases the planets will align and allow this to work anyway. // If you rely on and promote this, you are actively noncompliant with // PSR-4. $c3 = new \Foo\Bar\BUZ(); $c4 = new \Foo\Bar\Buz(); var_dump($c3 == $c4);

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0120.00318.28
8.3.50.0130.00516.36
8.3.40.0070.00718.97
8.3.30.0070.00718.62
8.3.20.0090.00618.90
8.3.10.0090.00020.72
8.3.00.0040.00417.63
8.2.180.0160.00616.75
8.2.170.0110.00422.96
8.2.160.0080.00622.17
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00319.77
8.2.110.0060.00319.34
8.2.100.0090.00317.84
8.2.90.0040.00419.17
8.2.80.0030.00517.97
8.2.70.0030.00617.62
8.2.60.0040.00717.80
8.2.50.0040.00418.07
8.2.40.0000.00818.09
8.2.30.0080.00018.27
8.2.20.0000.00717.82
8.2.10.0080.00017.91
8.2.00.0080.00017.74
8.1.280.0100.00725.92
8.1.270.0030.00523.99
8.1.260.0150.00326.35
8.1.250.0080.00028.09
8.1.240.0030.01019.25
8.1.230.0060.00617.64
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0090.00017.47
8.1.190.0030.00617.68
8.1.180.0030.00618.10
8.1.170.0000.00918.93
8.1.160.0000.00819.02
8.1.150.0000.00818.64
8.1.140.0060.00317.49
8.1.130.0040.00417.79
8.1.120.0040.00417.51
8.1.110.0040.00417.50
8.1.100.0000.00817.58
8.1.90.0040.00417.50
8.1.80.0030.00717.54
8.1.70.0070.00017.46
8.1.60.0000.00817.74
8.1.50.0080.00017.48
8.1.40.0030.00617.54
8.1.30.0040.00417.77
8.1.20.0080.00017.62
8.1.10.0040.00417.59
8.1.00.0050.00317.47
8.0.300.0040.00418.77
8.0.290.0050.00217.00
8.0.280.0000.00818.61
8.0.270.0030.00317.30
8.0.260.0080.00018.64
8.0.250.0070.00017.17
8.0.240.0030.00517.07
8.0.230.0050.00217.07
8.0.220.0070.00017.09
8.0.210.0030.00316.95
8.0.200.0030.00317.09
8.0.190.0030.00517.09
8.0.180.0040.00417.15
8.0.170.0030.00717.02
8.0.160.0000.00717.07
8.0.150.0040.00416.93
8.0.140.0120.00016.94
8.0.130.0000.00513.48
8.0.120.0040.00416.98
8.0.110.0000.00917.10
8.0.100.0040.00417.01
8.0.90.0060.00317.04
8.0.80.0050.01017.11
8.0.70.0040.00416.96
8.0.60.0000.00717.08
8.0.50.0060.00316.93
8.0.30.0080.01317.18
8.0.20.0080.01217.33
8.0.10.0080.00017.09
8.0.00.0100.00816.91
7.4.330.0020.00214.71
7.4.320.0070.00016.58
7.4.300.0070.00016.70
7.4.290.0000.00816.57
7.4.280.0030.00616.65
7.4.270.0000.00716.61
7.4.260.0000.00513.30
7.4.250.0030.00616.64
7.4.240.0030.00516.65
7.4.230.0000.00716.46
7.4.220.0100.00716.66
7.4.210.0060.01116.69
7.4.200.0030.00516.76
7.4.190.0030.00316.60
7.4.160.0060.00916.54
7.4.150.0170.00317.07
7.4.140.0060.01217.21
7.4.130.0030.01516.61
7.4.120.0080.01016.57
7.4.110.0100.01316.65
7.4.100.0070.01416.74
7.4.90.0090.00916.60
7.4.80.0120.00618.80
7.4.70.0120.01216.51
7.4.60.0100.01416.61
7.4.50.0040.00416.75
7.4.40.0050.00722.26
7.4.30.0120.00416.63
7.4.00.0040.01115.18
7.3.330.0030.00313.38
7.3.320.0030.00313.36
7.3.310.0030.00316.40
7.3.300.0030.00316.48
7.3.290.0130.00316.55
7.3.280.0090.00716.53
7.3.270.0110.00717.07
7.3.260.0070.01318.24
7.3.250.0120.00716.60
7.3.240.0110.00716.54
7.3.230.0090.00916.54
7.3.210.0080.01116.67
7.3.200.0120.00619.39
7.3.190.0120.00616.67
7.3.180.0120.00616.60
7.3.170.0090.01216.63
7.3.160.0030.01216.70
7.3.120.0130.00314.93
7.2.330.0080.01116.59
7.2.320.0000.01716.86
7.2.310.0160.00316.81
7.2.300.0070.01016.74
7.2.290.0170.00716.55
7.2.60.0040.01116.67
7.2.00.0000.01119.11
7.1.200.0040.00815.91
7.1.100.0030.01018.27
7.1.70.0000.00817.27
7.1.60.0100.01019.40
7.1.50.0070.01417.20
7.1.00.0030.07322.43
7.0.200.0000.00716.68
7.0.140.0100.06722.02
7.0.120.0000.03322.03
7.0.60.0070.08019.90
7.0.50.0030.04017.89
7.0.40.0070.05020.22
7.0.30.0170.04720.03
7.0.20.0170.07320.28
7.0.10.0370.07020.11
7.0.00.0270.04020.21
5.6.280.0070.07021.14
5.6.210.0170.07020.61
5.6.200.0070.05318.13
5.6.190.0200.08320.43
5.6.180.0130.04720.39
5.6.170.0170.04720.63
5.6.160.0200.06320.46
5.6.150.0200.04720.41
5.6.140.0200.04320.42
5.6.130.0230.04020.51
5.6.120.0130.04320.34
5.6.110.0100.04720.16
5.6.100.0230.04320.50
5.6.90.0130.04320.43
5.6.80.0330.02719.63
5.6.70.0100.04319.72
5.6.60.0200.05319.56
5.6.50.0130.04719.72
5.6.40.0200.08019.61
5.6.30.0130.04319.89
5.6.20.0200.08019.55
5.6.10.0130.05019.73
5.6.00.0130.05319.63
5.5.350.0270.06320.35
5.5.340.0030.04318.01
5.5.330.0070.04720.32
5.5.320.0030.05320.35
5.5.310.0230.07320.20
5.5.300.0270.05020.21
5.5.290.0400.05320.00
5.5.280.0330.03320.14
5.5.270.0170.06020.12
5.5.260.0130.04320.04
5.5.250.0130.05320.03
5.5.240.0070.04719.37
5.5.230.0200.05319.61
5.5.220.0170.03719.54
5.5.210.0130.06319.59
5.5.200.0230.03319.66
5.5.190.0270.03319.57
5.5.180.0170.04019.66
5.5.160.0230.05319.66
5.5.150.0170.03719.39
5.5.140.0230.06019.66
5.5.130.0270.05319.34
5.5.120.0270.05319.55
5.5.110.0270.07719.67
5.5.100.0300.03719.30
5.5.90.0300.07019.56
5.5.80.0270.07719.24
5.5.70.0270.03719.51
5.5.60.0300.07019.37
5.5.50.0200.08319.24
5.5.40.0300.05019.21
5.5.30.0270.05319.44
5.5.20.0230.03319.43
5.5.10.0170.04019.29
5.5.00.0230.04319.51
5.4.450.0230.04319.19
5.4.440.0230.07019.49
5.4.430.0230.06319.59
5.4.420.0200.03319.41
5.4.410.0170.03719.41
5.4.400.0170.03318.87
5.4.390.0100.07318.86
5.4.380.0130.04018.86
5.4.370.0270.03319.02
5.4.360.0100.05318.86
5.4.350.0130.04019.09
5.4.340.0130.04019.16
5.4.320.0100.04318.94
5.4.310.0170.03319.27
5.4.300.0200.06018.98
5.4.290.0130.07319.13
5.4.280.0330.06319.18
5.4.270.0230.07319.21
5.4.260.0170.05718.86
5.4.250.0300.04019.15
5.4.240.0230.07018.86
5.4.230.0200.07319.08
5.4.220.0270.04019.15
5.4.210.0230.03318.99
5.4.200.0200.03718.86
5.4.190.0200.05719.28
5.4.180.0200.06019.15
5.4.170.0100.05719.20
5.4.160.0170.04019.23
5.4.150.0170.05319.14
5.4.140.0370.06016.35
5.4.130.0200.06316.50
5.4.120.0230.07016.46
5.4.110.0170.04316.44
5.4.100.0200.07016.40
5.4.90.0270.03716.31
5.4.80.0200.07016.49
5.4.70.0270.06016.30
5.4.60.0230.06716.32
5.4.50.0230.03016.41
5.4.40.0200.04316.57
5.4.30.0300.06716.34
5.4.20.0270.07016.39
5.4.10.0200.07716.47
5.4.00.0170.07316.02
5.3.290.0130.05714.72
5.3.280.0270.05714.50
5.3.270.0300.06714.63
5.3.260.0200.03314.54
5.3.250.0270.04714.71
5.3.240.0200.05314.64
5.3.230.0200.07314.68
5.3.220.0270.07014.58
5.3.210.0170.04314.59
5.3.200.0270.06714.60
5.3.190.0230.06714.58
5.3.180.0200.03314.61
5.3.170.0200.05714.58
5.3.160.0270.07014.46
5.3.150.0200.05014.58
5.3.140.0300.06014.58
5.3.130.0230.07714.63
5.3.120.0270.07014.48
5.3.110.0300.07314.63
5.3.100.0200.06714.06
5.3.90.0230.04714.04
5.3.80.0200.03714.08
5.3.70.0170.05014.18
5.3.60.0330.05014.02
5.3.50.0300.06013.85
5.3.40.0200.06314.13
5.3.30.0370.07713.84
5.3.20.0170.05713.76
5.3.10.0170.03313.64
5.3.00.0170.03013.64
5.2.170.0230.06012.66
5.2.160.0300.03312.66
5.2.150.0170.06712.66
5.2.140.0230.05712.66
5.2.130.0100.06312.66
5.2.120.0170.06012.66
5.2.110.0130.04312.66
5.2.100.0170.05712.66
5.2.90.0130.03012.66
5.2.80.0170.06012.66
5.2.70.0170.05012.66
5.2.60.0270.02312.66
5.2.50.0200.02712.66
5.2.40.0130.03312.66
5.2.30.0230.02712.66
5.2.20.0200.05012.66
5.2.10.0170.06012.66
5.2.00.0130.05012.66
5.1.60.0270.04012.66
5.1.50.0200.04712.66
5.1.40.0100.05712.66
5.1.30.0130.04312.66
5.1.20.0170.05312.66
5.1.10.0100.04712.66
5.1.00.0130.03712.66
5.0.50.0100.04012.66
5.0.40.0070.03712.66
5.0.30.0100.05312.66
5.0.20.0100.03712.66
5.0.10.0130.03712.66
5.0.00.0130.05712.66
4.4.90.0070.02712.66
4.4.80.0100.03312.66
4.4.70.0030.04012.66
4.4.60.0070.04012.66
4.4.50.0130.03012.66
4.4.40.0070.05312.66
4.4.30.0100.03312.66
4.4.20.0070.03712.66
4.4.10.0100.02712.66
4.4.00.0070.05712.66
4.3.110.0100.03312.66
4.3.100.0100.03312.66
4.3.90.0100.03012.66
4.3.80.0100.03312.66
4.3.70.0070.01712.66
4.3.60.0070.03312.66
4.3.50.0070.01712.66
4.3.40.0130.04712.66
4.3.30.0030.01312.66
4.3.20.0030.03312.66
4.3.10.0070.03312.66
4.3.00.0030.01312.66

preferences:
35.91 ms | 401 KiB | 5 Q