3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); ini_set('display_errors', 1); class system_tags { function __call($name, $params) { return '(METHOD "' . $name . '" WAS CALLED WITH PARAMS ' . var_export($params) . ')'; } } class App { function run() { // Prerequisites. $system_tags = new system_tags(); $core = new \stdClass(); $core->tags = array( 'hello' => 'tagHelloMethod(1, 2)', 'world' => 'tagWorldMethod(3, 4)', ); // Approach 1. $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withStrReplace($core, $system_tags); echo $this->template . "\n"; // Approach 2. $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withRegexReplaceCallback($core, $system_tags); echo $this->template . "\n"; } function withStrReplace($core, $system_tags) { foreach($core->tags as $tag_name => $tag_method) { $this->template = str_replace( '{' . $tag_name . '}', eval('$system_tags->' . $tag_method . ';'), $this->template ); } } function withRegexReplaceCallback($core, $system_tags) { $callback = static function ($matches) use (& $tag_method, $system_tags) { return eval('$system_tags->' . $tag_method . ';'); }; foreach($core->tags as $tag_name => $tag_method) { $this->template = preg_replace_callback( '/\{' . preg_quote($tag_name) . '\}/', $callback, $this->template ); } } } $app = new App(); $app->run();

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.00617.00
8.3.50.0110.00522.25
8.3.40.0080.00819.09
8.3.30.0000.01419.26
8.3.20.0000.00720.29
8.3.10.0080.00021.94
8.3.00.0060.00319.63
8.2.180.0120.00616.88
8.2.170.0110.00422.96
8.2.160.0040.01120.36
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0050.00319.76
8.2.110.0120.00619.21
8.2.100.0030.00917.88
8.2.90.0080.00019.22
8.2.80.0000.00917.97
8.2.70.0060.00317.88
8.2.60.0060.00317.93
8.2.50.0060.00318.07
8.2.40.0040.00418.22
8.2.30.0040.00418.24
8.2.20.0040.00418.04
8.2.10.0000.00818.23
8.2.00.0050.00317.84
8.1.280.0170.00325.92
8.1.270.0100.00018.93
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00622.66
8.1.230.0060.00617.82
8.1.220.0030.00517.89
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0000.00817.60
8.1.180.0060.00318.10
8.1.170.0030.00518.87
8.1.160.0000.00722.03
8.1.150.0000.00718.86
8.1.140.0030.00517.68
8.1.130.0070.00017.92
8.1.120.0070.00017.54
8.1.110.0000.00717.50
8.1.100.0040.00417.52
8.1.90.0030.00517.68
8.1.80.0050.00217.57
8.1.70.0000.00717.63
8.1.60.0060.00317.79
8.1.50.0030.00517.75
8.1.40.0030.00517.60
8.1.30.0040.00417.84
8.1.20.0000.00817.84
8.1.10.0030.00517.60
8.1.00.0050.00317.75
8.0.300.0080.00018.77
8.0.290.0040.00416.63
8.0.280.0030.00318.57
8.0.270.0070.00017.36
8.0.260.0000.00617.18
8.0.250.0070.00017.20
8.0.240.0070.00017.14
8.0.230.0000.00717.20
8.0.220.0040.00417.05
8.0.210.0000.00717.02
8.0.200.0000.00717.09
8.0.190.0040.00417.02
8.0.180.0000.00917.06
8.0.170.0000.00817.14
8.0.160.0090.00017.16
8.0.150.0050.00317.00
8.0.140.0040.00717.04
8.0.130.0070.00013.56
8.0.120.0080.00017.05
8.0.110.0070.00017.05
8.0.100.0060.00317.08
8.0.90.0000.00817.12
8.0.80.0030.01417.13
8.0.70.0040.00417.00
8.0.60.0040.00416.97
8.0.50.0000.00717.11
8.0.30.0150.01017.26
8.0.20.0130.01117.40
8.0.10.0000.00717.06
8.0.00.0060.01116.86
7.4.330.0030.00315.11
7.4.320.0050.00216.76
7.4.300.0000.00716.64
7.4.290.0070.00016.73
7.4.280.0040.00416.68
7.4.270.0030.00316.75
7.4.260.0040.00416.72
7.4.250.0070.00016.76
7.4.240.0070.00116.78
7.4.230.0040.00416.91
7.4.220.0150.00716.81
7.4.210.0120.00316.73
7.4.200.0040.00416.69
7.4.160.0150.00316.66
7.4.150.0120.00617.40
7.4.140.0170.00517.86
7.4.130.0110.00616.86
7.4.120.0080.01116.67
7.4.110.0130.01116.68
7.4.100.0100.00716.70
7.4.90.0070.01016.52
7.4.80.0070.01019.39
7.4.70.0070.01116.78
7.4.60.0070.01016.78
7.4.50.0050.00016.84
7.4.40.0100.00616.71
7.4.30.0100.01316.75
7.4.00.0090.00314.97
7.3.330.0000.00513.34
7.3.320.0100.00513.47
7.3.310.0040.00416.54
7.3.300.0070.00016.31
7.3.290.0070.00916.52
7.3.280.0100.00916.49
7.3.270.0060.01217.40
7.3.260.0070.01116.85
7.3.250.0080.01016.67
7.3.240.0050.01116.57
7.3.230.0100.01016.65
7.3.210.0040.01316.77
7.3.200.0060.01119.39
7.3.190.0050.01116.50
7.3.180.0060.00916.75
7.3.170.0070.01416.83
7.3.160.0180.00616.57
7.2.330.0160.00617.03
7.2.320.0090.01416.94
7.2.310.0080.01416.79
7.2.300.0070.01016.73
7.2.290.0040.01516.86
7.2.00.0040.01119.50
7.1.100.0140.00318.23
7.1.70.0040.00417.13
7.1.60.0210.00419.50
7.1.50.0170.00717.25
7.1.00.0030.08022.45
7.0.200.0100.00015.31
7.0.140.0070.06721.93
7.0.60.0170.07720.04
7.0.50.0070.08017.95
7.0.40.0070.04020.16
7.0.30.0230.05720.09
7.0.20.0300.05720.13
7.0.10.0270.06020.21
7.0.00.0130.06320.08
5.6.280.0030.07320.94
5.6.210.0070.06320.48
5.6.200.0000.04718.18
5.6.190.0130.04320.50
5.6.180.0230.05020.56
5.6.170.0270.08020.60
5.6.160.0070.06320.41
5.6.150.0130.07318.16
5.6.140.0100.07718.14
5.6.130.0070.04018.15
5.6.120.0130.04321.07
5.6.110.0170.06321.00
5.6.100.0100.08321.06
5.6.90.0200.07321.08
5.6.80.0130.06020.39
5.6.70.0230.07020.39
5.5.350.0070.08720.54
5.5.340.0030.04317.95
5.5.330.0000.04320.29
5.5.320.0030.09320.57
5.5.310.0300.04720.36
5.5.300.0130.07317.95
5.5.290.0070.08318.04
5.5.280.0100.03720.90
5.5.270.0130.07720.86
5.5.260.0130.07020.74
5.5.250.0130.07720.79
5.5.240.0100.06020.25
5.4.450.0570.05319.61
5.4.440.1200.05019.47
5.4.430.0730.07019.59
5.4.420.1070.05019.33
5.4.410.0900.06719.45
5.4.400.0130.06318.80
5.4.390.0330.04018.75
5.4.380.0200.05718.75
5.4.370.0200.05018.58
5.4.360.0330.05318.62
5.4.350.0270.07018.74
5.4.340.0200.05318.73
5.4.320.0270.04718.69
5.4.310.0170.05318.82
5.4.300.0170.05718.48
5.4.290.0300.04318.54
5.4.280.0170.06018.62
5.4.270.0170.05718.73
5.4.260.0170.05718.72
5.4.250.0230.05318.61
5.4.240.0200.05318.77
5.4.230.0170.05718.76
5.4.220.0130.06318.72
5.4.210.0270.04718.57
5.4.200.0330.03316.69
5.4.190.0170.06318.76
5.4.180.0200.05018.72
5.4.170.0330.05018.67
5.4.160.0270.04718.70
5.4.150.0270.04718.55
5.4.140.0130.06016.27
5.4.130.0270.04316.34
5.4.120.0200.06316.25
5.4.110.0200.04716.27
5.4.100.0200.05016.29
5.4.90.0130.05716.18
5.4.80.0170.06016.17
5.4.70.0230.04716.44
5.4.60.0070.06016.21
5.4.50.0230.04716.28
5.4.40.0230.05316.25
5.4.30.0170.07016.31
5.4.20.0170.05016.16
5.4.10.0170.05016.25
5.4.00.0200.04715.68
5.3.290.0170.05314.79
5.3.280.0330.05314.67
5.3.270.0300.06314.79
5.3.260.0300.04014.66
5.3.250.0170.05314.73
5.3.240.0130.05714.74
5.3.230.0200.05014.72
5.3.220.0200.05014.71
5.3.210.0170.05714.78
5.3.200.0230.04714.62
5.3.190.0100.06014.76
5.3.180.0330.04314.57
5.3.170.0130.05714.64
5.3.160.0170.08014.63
5.3.150.0270.06314.56
5.3.140.0200.05314.62
5.3.130.0270.04314.73
5.3.120.0270.04714.75
5.3.110.0100.06714.59
5.3.100.0200.05014.34
5.3.90.0200.05314.20
5.3.80.0130.05714.17
5.3.70.0230.04714.20
5.3.60.0230.04714.14
5.3.50.0270.05313.98
5.3.40.0300.04714.09
5.3.30.0300.06713.94
5.3.20.0230.05013.72
5.3.10.0200.06313.67
5.3.00.0270.05013.79
5.2.170.0030.05311.29
5.2.160.0200.03311.16
5.2.150.0130.06011.20
5.2.140.0170.04711.20
5.2.130.0100.04711.12
5.2.120.0130.04011.25
5.2.110.0270.04711.34
5.2.100.0300.04711.34
5.2.90.0130.04311.17
5.2.80.0170.04011.22
5.2.70.0130.06311.17
5.2.60.0170.05011.17
5.2.50.0170.04011.09
5.2.40.0100.06011.14
5.2.30.0170.05311.21
5.2.20.0200.04311.06
5.2.10.0170.03710.93
5.2.00.0130.04010.84
5.1.60.0100.03710.19
5.1.50.0170.0309.99
5.1.40.0200.02710.02
5.1.30.0130.04010.45
5.1.20.0070.04310.47
5.1.10.0270.04010.17
5.1.00.0230.04010.27
5.0.50.0170.0338.75
5.0.40.0130.0238.62
5.0.30.0170.0508.28
5.0.20.0070.0378.39
5.0.10.0070.0278.20
5.0.00.0070.0438.17
4.4.90.0070.0305.99
4.4.80.0100.0275.94
4.4.70.0100.0175.91
4.4.60.0130.0175.91
4.4.50.0000.0305.96
4.4.40.0070.0335.94
4.4.30.0070.0235.91
4.4.20.0030.0275.98
4.4.10.0130.0175.99
4.4.00.0070.0335.98
4.3.110.0170.0135.93
4.3.100.0100.0205.89
4.3.90.0100.0305.84
4.3.80.0070.0405.85
4.3.70.0070.0205.93
4.3.60.0030.0335.90
4.3.50.0030.0235.84
4.3.40.0130.0275.84
4.3.30.0030.0234.58
4.3.20.0070.0204.66
4.3.10.0030.0234.61
4.3.00.0130.0177.32

preferences:
43.79 ms | 401 KiB | 5 Q