3v4l.org

run code in 300+ PHP versions simultaneously
<?php class interpreter { private $_code; public function __construct($code) { if(!is_string($code)) exit('Error while parsing code; Code not conformal.'); $this->_code = $code; $this->parser(); } public function parser($code = null) { if($code === null) $code = $this->_code; $calls = []; $variables = []; $conditions = []; preg_match('#(.*)\((.*)\)#', $code, $calls); preg_match('#if\((.*)\) \{(.*)\}#s', $code, $conditions); if($conditions && isset($conditions[0])) $this->conditions_ifelse($conditions); if($calls && isset($calls[0])) $this->calls($calls); } private function calls(array $calls) { switch($calls[1]) { case 'print': $this->func_print($calls[2]); break; } } private function condition_ifelse(array $conditions) { if(!preg_match('#(.*)(==|===|\<|\<=|\>|\>=|!=|!==|&&|\|\||AND|OR|XOR)(.*)#i', $conditions[1])) exit('Condition parsing error.'); } } abstract class lang { const version = 0.1; } class console extends lang { } class out extends console { public function println($arg) { if(preg_match('#^("|\')(.*)("|\')$#', $arg)) $arg = preg_replace('#^("|\')(.*)("|\')$#', '$2', $arg); echo($arg); } } $code = <<<CODE int var = 1; if(var == 1) { console.out.println("Hello World!"); } else { console.out.println("Hi!"); } CODE; $program = new interpreter($code);

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.0140.00716.88
8.3.50.0160.00316.76
8.3.40.0140.00719.14
8.3.30.0040.01518.95
8.3.20.0040.00420.35
8.3.10.0080.00021.95
8.3.00.0040.00423.60
8.2.180.0070.00718.66
8.2.170.0090.00622.96
8.2.160.0030.01020.52
8.2.150.0000.00824.18
8.2.140.0070.00024.66
8.2.130.0100.00018.21
8.2.120.0050.00326.35
8.2.110.0090.00022.17
8.2.100.0000.01117.93
8.2.90.0030.00519.36
8.2.80.0050.00317.97
8.2.70.0090.00017.84
8.2.60.0000.00818.05
8.2.50.0050.00518.07
8.2.40.0040.00422.48
8.2.30.0040.00419.43
8.2.20.0040.00417.90
8.2.10.0000.00818.08
8.2.00.0030.00618.23
8.1.280.0130.00325.92
8.1.270.0060.00324.00
8.1.260.0050.00328.09
8.1.250.0050.00228.09
8.1.240.0090.00923.80
8.1.230.0110.00018.98
8.1.220.0080.00017.77
8.1.210.0080.00018.77
8.1.200.0100.00017.35
8.1.190.0000.00817.48
8.1.180.0040.00418.10
8.1.170.0030.00518.71
8.1.160.0040.00420.81
8.1.150.0000.00718.98
8.1.140.0030.00519.57
8.1.130.0050.00217.71
8.1.120.0000.00717.62
8.1.110.0050.00317.58
8.1.100.0070.00017.58
8.1.90.0040.00717.54
8.1.80.0040.00417.63
8.1.70.0050.00317.50
8.1.60.0030.00617.59
8.1.50.0000.00817.69
8.1.40.0000.00817.73
8.1.30.0090.00017.74
8.1.20.0040.00417.73
8.1.10.0020.00517.66
8.1.00.0080.00017.61
8.0.300.0040.00418.77
8.0.290.0050.00317.00
8.0.280.0030.00318.41
8.0.270.0030.00317.37
8.0.260.0030.00317.30
8.0.250.0000.00717.20
8.0.240.0070.00017.08
8.0.230.0000.00717.08
8.0.220.0000.00717.10
8.0.210.0070.00017.11
8.0.200.0030.00317.22
8.0.190.0060.00617.19
8.0.180.0040.00417.11
8.0.170.0030.00617.13
8.0.160.0000.00817.01
8.0.150.0000.00717.12
8.0.140.0000.00817.00
8.0.130.0070.00013.59
8.0.120.0000.00916.99
8.0.110.0030.00517.13
8.0.100.0040.00416.99
8.0.90.0080.00017.22
8.0.80.0140.00717.06
8.0.70.0050.00316.92
8.0.60.0000.00817.01
8.0.50.0070.00017.12
8.0.30.0100.01017.15
8.0.20.0110.00717.41
8.0.10.0000.00817.14
8.0.00.0110.01116.98
7.4.330.0050.00016.80
7.4.320.0030.00316.82
7.4.300.0030.00316.69
7.4.290.0030.00316.73
7.4.280.0080.00016.58
7.4.270.0070.00016.83
7.4.260.0030.00716.71
7.4.250.0050.00316.60
7.4.240.0010.00616.74
7.4.230.0030.00316.58
7.4.220.0090.01216.84
7.4.210.0050.01016.71
7.4.200.0030.00316.72
7.4.160.0070.01016.91
7.4.150.0080.00917.40
7.4.140.0150.01217.86
7.4.130.0070.01716.83
7.4.120.0090.00816.89
7.4.110.0070.01016.68
7.4.100.0060.01316.80
7.4.90.0130.00616.70
7.4.80.0080.00819.39
7.4.70.0070.01016.72
7.4.60.0060.00916.80
7.4.50.0120.00316.55
7.4.40.0100.00716.88
7.4.30.0060.01216.72
7.4.00.0070.01015.22
7.3.330.0000.00613.43
7.3.320.0000.00513.46
7.3.310.0000.00716.71
7.3.300.0000.00716.65
7.3.290.0080.00916.53
7.3.280.0090.01216.61
7.3.270.0000.01617.40
7.3.260.0070.01116.75
7.3.240.0090.01016.71
7.3.230.0030.01316.53
7.3.210.0060.01716.84
7.3.200.0050.01416.56
7.3.190.0110.00716.63
7.3.180.0060.00916.75
7.3.170.0090.00616.95
7.3.160.0070.01016.80
7.2.330.0090.01016.68
7.2.320.0130.01016.73
7.2.310.0100.00716.90
7.2.300.0160.00516.94
7.2.290.0110.01216.95
7.2.60.0130.00916.74
7.2.50.0130.00017.03
7.2.00.0000.01519.83
7.1.200.0100.00316.00
7.1.70.0070.00417.47
7.1.60.0140.00719.27
7.1.50.0070.00417.34
7.1.00.0030.07722.35
7.0.200.0050.00317.00
7.0.60.0270.06021.74
7.0.50.0070.07317.95
7.0.40.0070.08320.15
7.0.30.0230.04720.11
7.0.20.0370.06720.29
7.0.10.0030.08020.17
7.0.00.0130.07720.34
5.6.280.0000.06721.01
5.6.210.0130.08020.68
5.6.200.0100.07318.27
5.6.190.0070.08320.47
5.6.180.0530.06720.64
5.6.170.0330.07320.71
5.6.160.0130.07320.51
5.6.150.0130.07018.15
5.6.140.0030.06718.28
5.6.130.0100.08018.28
5.6.120.0070.08321.01
5.6.110.0100.08321.00
5.6.100.0000.04321.12
5.6.90.0070.04021.11
5.6.80.0070.07020.55
5.5.350.0030.07320.32
5.5.340.0070.08017.99
5.5.330.0000.08020.47
5.5.320.0170.04320.30
5.5.310.0400.06720.27
5.5.300.0100.07717.97
5.5.290.0100.08018.00
5.5.280.0070.05320.76
5.5.270.0070.03720.80
5.5.260.0030.05720.88
5.5.250.0070.09020.70
5.5.240.0170.07320.16

preferences:
51.43 ms | 400 KiB | 5 Q