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)'; } } class App { function run() { // Prerequisites. $system_tags = new system_tags(); $core = new \stdClass(); $core->tags = array( 'hello' => 'tagHelloMethod', 'world' => 'tagWorldMethod', ); $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withStrReplace($core, $system_tags); $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withRegexReplaceCallback($core, $system_tags); } function withStrReplace($core, $system_tags) { foreach($core->tags as $tag_name => $tag_method) { $this->template = str_replace( '{' . $tag_name . '}', $system_tags->{$tag_method}(), $this->template ); } echo $this->template . "\n"; } function withRegexReplaceCallback($core, $system_tags) { $callback = static function ($matches) use (& $tag_method, $system_tags) { return $system_tags->{$tag_method}(); }; foreach($core->tags as $tag_name => $tag_method) { $this->template = preg_replace_callback( '/\{' . preg_quote($tag_name) . '\}/', $callback, $this->template ); } echo $this->template . "\n"; } } $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.0070.01117.00
8.3.50.0090.00918.23
8.3.40.0000.01919.09
8.3.30.0120.00319.02
8.3.20.0000.00820.08
8.3.10.0050.00321.73
8.3.00.0040.00419.51
8.2.180.0090.00918.66
8.2.170.0070.01122.96
8.2.160.0080.00620.35
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.66
8.2.110.0070.00322.38
8.2.100.0070.00417.75
8.2.90.0000.00819.14
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0000.00818.04
8.2.50.0080.00018.07
8.2.40.0030.00718.16
8.2.30.0040.00418.04
8.2.20.0030.00517.85
8.2.10.0000.00818.10
8.2.00.0060.00317.73
8.1.280.0140.00425.92
8.1.270.0040.00420.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0050.00523.89
8.1.230.0110.00018.92
8.1.220.0080.00017.74
8.1.210.0000.00818.77
8.1.200.0100.00017.50
8.1.190.0060.00317.47
8.1.180.0050.00318.10
8.1.170.0040.00420.40
8.1.160.0040.00421.97
8.1.150.0070.00018.87
8.1.140.0000.00717.49
8.1.130.0030.00317.84
8.1.120.0040.00417.64
8.1.110.0030.00517.63
8.1.100.0070.00017.50
8.1.90.0070.00017.53
8.1.80.0000.00717.65
8.1.70.0000.00717.60
8.1.60.0060.00317.81
8.1.50.0000.00817.57
8.1.40.0090.00017.57
8.1.30.0040.00417.81
8.1.20.0080.00017.80
8.1.10.0000.00817.70
8.1.00.0000.00817.57
8.0.300.0000.00718.77
8.0.290.0000.00816.75
8.0.280.0050.00318.48
8.0.270.0000.00717.22
8.0.260.0030.00317.40
8.0.250.0030.00317.12
8.0.240.0000.00717.07
8.0.230.0000.00817.12
8.0.220.0000.00717.04
8.0.210.0040.00416.98
8.0.200.0030.00317.10
8.0.190.0030.00616.95
8.0.180.0040.00416.95
8.0.170.0050.00317.10
8.0.160.0080.00017.05
8.0.150.0060.00317.04
8.0.140.0020.00516.92
8.0.130.0000.00713.44
8.0.120.0050.00316.95
8.0.110.0070.00017.10
8.0.100.0000.00817.06
8.0.90.0040.00417.11
8.0.80.0120.00917.04
8.0.70.0070.00016.87
8.0.60.0080.00016.95
8.0.50.0050.00316.94
8.0.30.0140.00917.28
8.0.20.0060.01317.40
8.0.10.0000.00817.12
8.0.00.0100.00716.92
7.4.330.0000.00515.15
7.4.320.0040.00416.83
7.4.300.0040.00416.86
7.4.290.0000.00716.82
7.4.280.0060.00316.82
7.4.270.0000.00716.74
7.4.260.0040.00416.82
7.4.250.0000.00816.79
7.4.240.0030.00516.68
7.4.230.0000.00716.57
7.4.220.0090.01016.60
7.4.210.0140.00316.77
7.4.200.0050.00316.88
7.4.160.0150.00316.74
7.4.150.0130.01317.40
7.4.140.0060.01317.86
7.4.130.0060.01216.63
7.4.120.0070.01316.79
7.4.110.0120.01216.94
7.4.100.0070.01016.74
7.4.90.0090.00916.78
7.4.80.0090.00919.39
7.4.70.0150.00416.69
7.4.60.0100.00616.75
7.4.50.0050.00516.78
7.4.40.0060.01016.63
7.4.30.0120.00616.62
7.4.00.0060.00914.95
7.3.330.0000.00713.26
7.3.320.0000.01513.46
7.3.310.0070.00016.50
7.3.300.0030.00316.37
7.3.290.0110.00516.44
7.3.280.0100.01016.42
7.3.270.0090.00917.40
7.3.260.0140.01116.74
7.3.250.0110.00616.73
7.3.240.0040.01316.46
7.3.230.0100.00716.68
7.3.210.0100.01016.77
7.3.200.0030.01419.39
7.3.190.0030.01316.47
7.3.180.0070.01116.74
7.3.170.0150.00616.55
7.3.160.0030.01416.52
7.2.330.0140.01016.94
7.2.320.0100.01416.91
7.2.310.0130.00516.82
7.2.300.0150.00316.77
7.2.290.0110.01216.86
7.2.00.0060.00619.63
7.1.100.0060.00918.45
7.1.70.0000.00817.13
7.1.60.0080.01519.50
7.1.50.0070.01517.27
7.1.00.0000.07722.59
7.0.200.0120.00615.21
7.0.140.0000.07022.09
7.0.60.0000.04319.93
7.0.50.0000.04317.95
7.0.40.0200.07020.41
7.0.30.0300.07720.10
7.0.20.0400.06320.27
7.0.10.0330.07020.11
7.0.00.0200.06320.08
5.6.280.0000.07721.09
5.6.210.0030.08020.77
5.6.200.0070.05318.13
5.6.190.0100.07320.57
5.6.180.0300.07020.60
5.6.170.0330.07020.44
5.6.160.0070.04720.55
5.6.150.0070.04718.28
5.6.140.0030.08318.13
5.6.130.0100.05018.20
5.6.120.0230.07721.00
5.6.110.0030.09321.13
5.6.100.0130.05721.02
5.6.90.0100.08020.98
5.6.80.0100.08020.38
5.6.70.0170.08320.53
5.5.350.0100.07020.43
5.5.340.0070.03717.98
5.5.330.0170.07320.21
5.5.320.0070.04020.57
5.5.310.0330.07320.41
5.5.300.0000.05017.98
5.5.290.0100.08718.09
5.5.280.0030.09320.79
5.5.270.0130.03320.89
5.5.260.0130.05020.96
5.5.250.0070.08720.63
5.5.240.0030.04020.30
5.4.450.0370.05319.33
5.4.440.1170.06319.63
5.4.430.0300.03719.62
5.4.420.1000.05019.55
5.4.410.0270.05719.07
5.4.400.0170.05718.78
5.4.390.0330.04018.62
5.4.380.0230.05718.63
5.4.370.0130.06318.48
5.4.360.0200.05318.83
5.4.350.0330.04318.73
5.4.340.0270.05018.50
5.4.320.0200.05318.80
5.4.310.0230.06718.63
5.4.300.0200.05318.71
5.4.290.0270.04718.46
5.4.280.0200.05318.73
5.4.270.0230.05018.82
5.4.260.0230.05018.76
5.4.250.0270.05018.50
5.4.240.0200.05718.57
5.4.230.0230.07018.73
5.4.220.0200.06018.73
5.4.210.0170.05718.83
5.4.200.0300.04016.59
5.4.190.0230.05018.77
5.4.180.0130.06018.46
5.4.170.0230.05018.55
5.4.160.0370.05318.47
5.4.150.0300.07018.75
5.4.140.0200.05716.27
5.4.130.0200.05016.18
5.4.120.0230.05316.20
5.4.110.0200.06316.46
5.4.100.0330.06016.29
5.4.90.0300.06316.18
5.4.80.0270.06016.29
5.4.70.0300.06316.22
5.4.60.0230.05316.29
5.4.50.0130.05716.23
5.4.40.0100.07016.40
5.4.30.0200.04716.42
5.4.20.0170.05716.36
5.4.10.0130.05716.27
5.4.00.0270.04015.90
5.3.290.0230.05314.88
5.3.280.0170.05314.63
5.3.270.0300.07314.72
5.3.260.0230.05714.83
5.3.250.0270.04714.67
5.3.240.0300.05314.66
5.3.230.0230.07314.72
5.3.220.0270.05714.56
5.3.210.0200.05014.69
5.3.200.0170.05314.58
5.3.190.0270.05014.63
5.3.180.0170.05314.56
5.3.170.0300.04714.68
5.3.160.0300.05314.68
5.3.150.0200.05014.66
5.3.140.0230.05314.60
5.3.130.0270.04714.67
5.3.120.0200.05014.77
5.3.110.0230.05014.75
5.3.100.0070.06314.09
5.3.90.0230.05014.04
5.3.80.0170.05314.03
5.3.70.0230.07014.08
5.3.60.0130.05714.00
5.3.50.0230.05013.96
5.3.40.0170.05713.96
5.3.30.0330.06313.91
5.3.20.0030.06313.76
5.3.10.0270.04013.72
5.3.00.0100.06013.75
5.2.170.0130.04311.21
5.2.160.0230.04011.20
5.2.150.0130.06011.27
5.2.140.0130.04711.36
5.2.130.0170.05711.15
5.2.120.0200.05311.19
5.2.110.0170.05311.18
5.2.100.0130.04311.32
5.2.90.0200.03711.33
5.2.80.0170.04311.14
5.2.70.0170.05711.21
5.2.60.0200.04711.10
5.2.50.0200.03711.26
5.2.40.0100.04311.08
5.2.30.0130.04311.21
5.2.20.0130.05011.16
5.2.10.0200.03710.91
5.2.00.0170.04010.91
5.1.60.0170.03310.03
5.1.50.0130.03310.01
5.1.40.0230.03710.03
5.1.30.0100.04310.33
5.1.20.0070.04710.43
5.1.10.0100.03710.13
5.1.00.0170.03010.27
5.0.50.0130.0238.59
5.0.40.0100.0278.47
5.0.30.0070.0478.32
5.0.20.0100.0308.26
5.0.10.0070.0308.34
5.0.00.0130.0378.29
4.4.90.0030.0275.90
4.4.80.0070.0235.90
4.4.70.0100.0205.91
4.4.60.0100.0175.91
4.4.50.0030.0276.04
4.4.40.0070.0335.91
4.4.30.0070.0235.90
4.4.20.0070.0206.07
4.4.10.0000.0306.04
4.4.00.0100.0405.95
4.3.110.0070.0205.86
4.3.100.0130.0135.96
4.3.90.0070.0205.80
4.3.80.0070.0335.83
4.3.70.0070.0205.87
4.3.60.0030.0235.82
4.3.50.0030.0275.88
4.3.40.0030.0335.80
4.3.30.0000.0274.57
4.3.20.0030.0304.57
4.3.10.0000.0274.52
4.3.00.0070.0237.32

preferences:
42.32 ms | 400 KiB | 5 Q