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', ); // 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 . '}', $system_tags->{$tag_method}(), $this->template ); } } function withRegexReplaceCallback($core, $system_tags) { $callback = static function ($matches) use ($system_tags) { return $system_tags->{$match['method_name']}(); }; foreach($core->tags as $tag_name => $tag_method) { $this->template = preg_replace_callback( '/\{(?<method_name>' . 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.0070.00716.75
8.3.50.0110.00722.03
8.3.40.0110.01119.27
8.3.30.0090.00619.03
8.3.20.0080.00020.16
8.3.10.0060.00321.90
8.3.00.0040.00419.47
8.2.180.0090.00618.54
8.2.170.0110.00722.96
8.2.160.0140.00020.70
8.2.150.0030.00524.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00419.91
8.2.110.0040.00721.09
8.2.100.0090.00317.88
8.2.90.0040.00419.30
8.2.80.0000.00817.97
8.2.70.0030.00517.88
8.2.60.0080.00017.93
8.2.50.0030.00618.07
8.2.40.0000.00820.08
8.2.30.0080.00018.12
8.2.20.0040.00417.90
8.2.10.0000.00818.25
8.2.00.0030.00517.86
8.1.280.0140.00725.92
8.1.270.0090.00020.73
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00623.92
8.1.230.0120.00019.10
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0090.00017.60
8.1.190.0030.00517.47
8.1.180.0050.00318.10
8.1.170.0050.00320.41
8.1.160.0000.00822.00
8.1.150.0080.00018.97
8.1.140.0050.00217.66
8.1.130.0030.00317.83
8.1.120.0040.00417.63
8.1.110.0000.00917.56
8.1.100.0040.00417.56
8.1.90.0080.00017.67
8.1.80.0030.00517.48
8.1.70.0000.00717.64
8.1.60.0030.00617.78
8.1.50.0030.00517.61
8.1.40.0040.00417.70
8.1.30.0050.00317.74
8.1.20.0050.00317.79
8.1.10.0060.00317.75
8.1.00.0030.00517.62
8.0.300.0000.00718.77
8.0.290.0030.00717.00
8.0.280.0050.00218.50
8.0.270.0040.00417.39
8.0.260.0030.00317.31
8.0.250.0000.00717.11
8.0.240.0000.00617.07
8.0.230.0020.00517.26
8.0.220.0000.00716.99
8.0.210.0040.00417.11
8.0.200.0040.00417.13
8.0.190.0000.00717.11
8.0.180.0040.00417.08
8.0.170.0030.00617.20
8.0.160.0040.00417.03
8.0.150.0050.00317.10
8.0.140.0040.00417.14
8.0.130.0070.00013.50
8.0.120.0080.00017.05
8.0.110.0020.00517.18
8.0.100.0050.00317.16
8.0.90.0080.00016.96
8.0.80.0060.00917.18
8.0.70.0080.00017.15
8.0.60.0020.00516.92
8.0.50.0000.00717.00
8.0.30.0070.01517.50
8.0.20.0110.00817.40
8.0.10.0000.00817.17
8.0.00.0110.01017.06
7.4.330.0030.00315.16
7.4.320.0040.00416.80
7.4.300.0070.00016.89
7.4.290.0070.00016.77
7.4.280.0050.00316.89
7.4.270.0040.00416.70
7.4.260.0040.00416.82
7.4.250.0000.00716.73
7.4.240.0040.00416.76
7.4.230.0000.00716.93
7.4.220.0100.01016.62
7.4.210.0090.00616.91
7.4.200.0000.00716.82
7.4.160.0080.00816.67
7.4.150.0120.01317.40
7.4.140.0100.01217.86
7.4.130.0070.01016.79
7.4.120.0080.01416.92
7.4.110.0060.01616.79
7.4.100.0080.01316.58
7.4.90.0140.00316.87
7.4.80.0110.00619.39
7.4.70.0100.00716.76
7.4.60.0090.00916.64
7.4.50.0000.00616.76
7.4.40.0150.00316.86
7.4.30.0140.00716.76
7.4.00.0100.00715.29
7.3.330.0050.00013.46
7.3.320.0040.00913.42
7.3.310.0070.00016.42
7.3.300.0000.00716.67
7.3.290.0030.00616.46
7.3.280.0130.00616.57
7.3.270.0150.00917.40
7.3.260.0080.00916.65
7.3.250.0110.00716.60
7.3.240.0110.01116.61
7.3.230.0090.00916.59
7.3.210.0100.00616.62
7.3.200.0060.01219.39
7.3.190.0050.01116.63
7.3.180.0060.01116.67
7.3.170.0070.01416.60
7.3.160.0100.00616.66
7.2.330.0180.00616.89
7.2.320.0110.00617.00
7.2.310.0130.00816.67
7.2.300.0070.01017.01
7.2.290.0090.00916.78
7.2.60.0070.00316.98
7.2.50.0120.01317.00
7.2.00.0070.00719.85
7.1.200.0070.00316.02
7.1.100.0000.01417.92
7.1.70.0030.00617.11
7.1.60.0040.02119.50
7.1.50.0070.01817.00
7.1.00.0000.08022.30
7.0.200.0250.00015.06
7.0.140.0030.07722.10
7.0.60.0170.06019.96
7.0.50.0030.05317.88
7.0.40.0070.06320.18
7.0.30.0270.04320.17
7.0.20.0270.07720.20
7.0.10.0070.08020.31
7.0.00.0130.05020.27
5.6.280.0030.07320.84
5.6.210.0030.04020.62
5.6.200.0100.08318.25
5.6.190.0000.08020.52
5.6.180.0370.07320.50
5.6.170.0400.06720.47
5.6.160.0000.04320.54
5.6.150.0070.08018.28
5.6.140.0070.08018.16
5.6.130.0100.08318.17
5.6.120.0170.07321.15
5.6.110.0170.06721.13
5.6.100.0070.03720.97
5.6.90.0400.04321.14
5.6.80.0070.08320.38
5.6.70.3270.02720.40
5.5.350.0130.07020.32
5.5.340.0000.06318.14
5.5.330.0170.06720.40
5.5.320.0200.04720.32
5.5.310.0170.04020.32
5.5.300.0070.04717.96
5.5.290.0100.06717.94
5.5.280.0130.08320.98
5.5.270.0070.08020.74
5.5.260.0170.07320.77
5.5.250.0100.03720.61
5.5.240.0300.06020.17
5.4.450.0330.05719.53
5.4.440.0730.06319.39
5.4.430.0770.05719.55
5.4.420.1030.05019.65
5.4.410.0800.06019.48
5.4.400.0270.05718.88
5.4.390.0330.04318.79
5.4.380.0270.05718.75
5.4.370.0300.04718.55
5.4.360.0300.05318.78
5.4.350.0400.04018.48
5.4.340.0170.06018.81
5.4.320.0230.06018.74
5.4.310.0270.05318.75
5.4.300.0230.05318.76
5.4.290.0230.05018.84
5.4.280.0200.05318.79
5.4.270.0400.04018.79
5.4.260.0300.04718.75
5.4.250.0170.06018.59
5.4.240.0300.05018.59
5.4.230.0230.05018.56
5.4.220.0370.04718.48
5.4.210.0470.06318.47
5.4.200.0300.06016.63
5.4.190.0230.05318.50
5.4.180.0270.05018.77
5.4.170.0230.05318.75
5.4.160.0270.04718.76
5.4.150.0300.04718.60
5.4.140.0300.04316.30
5.4.130.0230.05316.25
5.4.120.0230.05016.30
5.4.110.0170.05316.45
5.4.100.0200.05316.29
5.4.90.0200.05716.30
5.4.80.0330.04016.47
5.4.70.0300.04316.20
5.4.60.0230.05016.29
5.4.50.0270.04316.43
5.4.40.0270.05016.28
5.4.30.0200.05716.26
5.4.20.0230.05016.31
5.4.10.0300.05016.22
5.4.00.0230.04715.70
5.3.290.0300.04714.63
5.3.280.0230.06014.61
5.3.270.0330.04714.71
5.3.260.0200.06014.90
5.3.250.0170.05714.67
5.3.240.0230.05014.79
5.3.230.0300.04714.66
5.3.220.0330.04314.61
5.3.210.0330.04314.69
5.3.200.0200.05714.78
5.3.190.0230.05314.63
5.3.180.0300.04314.74
5.3.170.0230.05314.57
5.3.160.0330.04014.79
5.3.150.0300.05714.69
5.3.140.0200.06314.77
5.3.130.0270.05014.76
5.3.120.0270.05314.67
5.3.110.0400.05714.67
5.3.100.0230.05314.22
5.3.90.0430.06014.07
5.3.80.0200.05314.09
5.3.70.0200.06314.03
5.3.60.0400.05014.12
5.3.50.0300.04014.01
5.3.40.0270.05014.25
5.3.30.0330.04014.23
5.3.20.0070.06013.74
5.3.10.0300.05013.81
5.3.00.0170.05313.71
5.2.170.0130.04711.29
5.2.160.0200.04311.20
5.2.150.0400.04011.36
5.2.140.0170.05011.28
5.2.130.0170.06011.15
5.2.120.0230.04011.22
5.2.110.0170.04311.34
5.2.100.0130.04711.12
5.2.90.0270.03711.34
5.2.80.0200.04011.09
5.2.70.0170.04311.24
5.2.60.0300.03711.07
5.2.50.0230.04711.08
5.2.40.0300.03711.06
5.2.30.0230.04311.10
5.2.20.0170.04011.08
5.2.10.0070.05011.08
5.2.00.0200.04010.76
5.1.60.0200.03010.13
5.1.50.0170.03010.03
5.1.40.0130.03710.20
5.1.30.0270.04010.57
5.1.20.0270.03710.59
5.1.10.0230.03010.09
5.1.00.0170.03310.28
5.0.50.0130.0278.58
5.0.40.0030.0338.52
5.0.30.0070.0478.24
5.0.20.0070.0308.24
5.0.10.0170.0238.23
5.0.00.0030.0438.26
4.4.90.0100.0235.93
4.4.80.0030.0305.91
4.4.70.0100.0235.97
4.4.60.0030.0235.91
4.4.50.0070.0235.92
4.4.40.0100.0375.94
4.4.30.0170.0175.94
4.4.20.0030.0276.05
4.4.10.0070.0236.09
4.4.00.0100.0336.04
4.3.110.0070.0235.95
4.3.100.0070.0235.92
4.3.90.0100.0205.83
4.3.80.0100.0335.89
4.3.70.0100.0175.84
4.3.60.0170.0175.84
4.3.50.0170.0205.88
4.3.40.0100.0335.81
4.3.30.0070.0204.69
4.3.20.0000.0274.55
4.3.10.0070.0204.52
4.3.00.0030.0207.32

preferences:
52.36 ms | 401 KiB | 5 Q