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 (& $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 ); } } } $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.0160.00317.13
8.3.50.0120.00722.20
8.3.40.0040.01119.00
8.3.30.0140.00019.06
8.3.20.0030.00520.30
8.3.10.0000.00721.73
8.3.00.0040.00419.63
8.2.180.0140.00418.79
8.2.170.0040.01822.96
8.2.160.0090.00620.30
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0000.00819.66
8.2.110.0000.00920.64
8.2.100.0090.00317.97
8.2.90.0030.00517.93
8.2.80.0030.00518.05
8.2.70.0000.00917.80
8.2.60.0060.00318.04
8.2.50.0000.00918.10
8.2.40.0080.00020.47
8.2.30.0000.00818.19
8.2.20.0050.00317.79
8.2.10.0040.00418.10
8.2.00.0060.00317.95
8.1.280.0090.00925.92
8.1.270.0040.00420.69
8.1.260.0050.00326.35
8.1.250.0090.00028.09
8.1.240.0030.00623.77
8.1.230.0110.00019.14
8.1.220.0060.00317.74
8.1.210.0030.00618.77
8.1.200.0000.00917.48
8.1.190.0060.00317.38
8.1.180.0090.00018.10
8.1.170.0040.00418.71
8.1.160.0080.00022.03
8.1.150.0080.00018.96
8.1.140.0040.00417.54
8.1.130.0070.00017.88
8.1.120.0000.00817.70
8.1.110.0080.00017.66
8.1.100.0000.00717.63
8.1.90.0000.00817.51
8.1.80.0000.00717.62
8.1.70.0000.00717.64
8.1.60.0030.00517.73
8.1.50.0000.00817.61
8.1.40.0000.00817.68
8.1.30.0030.00617.89
8.1.20.0000.00817.77
8.1.10.0040.00417.68
8.1.00.0000.00817.68
8.0.300.0060.00319.68
8.0.290.0080.00016.75
8.0.280.0000.00718.50
8.0.270.0030.00317.29
8.0.260.0030.00317.22
8.0.250.0000.00717.19
8.0.240.0030.00317.10
8.0.230.0000.00717.02
8.0.220.0080.00017.04
8.0.210.0050.00316.97
8.0.200.0030.00317.15
8.0.190.0040.00417.09
8.0.180.0070.00017.10
8.0.170.0080.00016.98
8.0.160.0030.00517.06
8.0.150.0040.00416.99
8.0.140.0040.00417.04
8.0.130.0050.00213.44
8.0.120.0050.00317.08
8.0.110.0030.00516.98
8.0.100.0050.00217.17
8.0.90.0000.00717.11
8.0.80.0060.00917.11
8.0.70.0000.00716.94
8.0.60.0050.00317.02
8.0.50.0050.00317.03
8.0.30.0150.01217.32
8.0.20.0140.00717.40
8.0.10.0000.00817.22
8.0.00.0060.01316.94
7.4.330.0030.00315.16
7.4.320.0070.00016.61
7.4.300.0000.00616.80
7.4.290.0000.00816.82
7.4.280.0040.00416.71
7.4.270.0040.00416.69
7.4.260.0000.00816.83
7.4.250.0000.00716.75
7.4.240.0060.00216.80
7.4.230.0000.00716.64
7.4.220.0140.01416.61
7.4.210.0090.00616.84
7.4.200.0030.00516.93
7.4.160.0160.00016.78
7.4.150.0100.00717.40
7.4.140.0110.01017.86
7.4.130.0050.01216.64
7.4.120.0080.01016.73
7.4.110.0120.01216.71
7.4.100.0120.00616.80
7.4.90.0070.01116.70
7.4.80.0040.01619.39
7.4.70.0100.00716.58
7.4.60.0060.01016.74
7.4.50.0060.00316.78
7.4.40.0060.01016.75
7.4.30.0090.00916.77
7.4.00.0120.00015.25
7.3.330.0000.00613.43
7.3.320.0120.00013.41
7.3.310.0070.00016.24
7.3.300.0070.00016.41
7.3.290.0080.00716.47
7.3.280.0110.00416.45
7.3.270.0090.00917.40
7.3.260.0090.00916.73
7.3.250.0080.01016.74
7.3.240.0130.00316.52
7.3.230.0120.00616.74
7.3.210.0030.01516.88
7.3.200.0070.01119.39
7.3.190.0070.01016.79
7.3.180.0070.01016.71
7.3.170.0100.00716.75
7.3.160.0100.00716.63
7.2.330.0080.02116.84
7.2.320.0070.01316.88
7.2.310.0070.01716.82
7.2.300.0130.00416.88
7.2.290.0170.00716.88
7.2.00.0060.00619.52
7.1.100.0080.00818.07
7.1.70.0030.00917.26
7.1.60.0110.00719.50
7.1.50.0110.00617.03
7.1.00.0000.08022.38
7.0.200.0090.00315.17
7.0.140.0030.07322.13
7.0.60.0070.03719.94
7.0.50.0070.03717.90
7.0.40.0170.05020.11
7.0.30.0330.07020.29
7.0.20.0200.05320.22
7.0.10.0170.05320.11
7.0.00.0100.06320.13
5.6.280.0070.09021.05
5.6.210.0030.05020.70
5.6.200.0130.04718.17
5.6.190.0070.04320.38
5.6.180.0200.08320.44
5.6.170.0270.04320.62
5.6.160.0000.04720.61
5.6.150.0070.04018.18
5.6.140.0030.04018.18
5.6.130.0070.05318.21
5.6.120.0170.07721.03
5.6.110.0100.09021.16
5.6.100.0170.07021.00
5.6.90.0070.07321.12
5.6.80.0100.07720.46
5.6.70.0170.07720.52
5.5.350.0130.08020.39
5.5.340.0000.06018.07
5.5.330.0070.04020.26
5.5.320.0270.07020.47
5.5.310.0230.05320.27
5.5.300.0100.07318.07
5.5.290.0000.07017.98
5.5.280.0100.07020.78
5.5.270.0070.08720.75
5.5.260.0100.04020.88
5.5.250.0200.06320.70
5.5.240.0030.03720.28
5.4.450.3130.04719.56
5.4.440.3230.04019.53
5.4.430.2830.04019.55
5.4.420.3230.04019.39
5.4.410.3170.04019.19
5.4.400.2900.04019.23
5.4.390.3130.04319.23
5.4.380.3130.03319.15
5.4.370.3230.03318.98
5.4.360.2700.03319.20
5.4.350.3030.04318.84
5.4.340.3270.03319.08
5.4.320.3170.04318.87
5.4.310.2070.03718.87
5.4.300.3430.04319.23
5.4.290.0200.03718.99
5.4.280.0030.06018.99
5.4.270.0000.04019.07
5.4.260.0300.04719.21
5.4.250.2900.03319.04
5.4.240.2370.03719.19
5.4.230.1600.03319.19
5.4.220.1370.04019.21
5.4.210.2670.04019.15
5.4.200.1400.03718.83
5.4.190.1600.03719.11
5.4.180.1530.03718.99
5.4.170.1700.03719.12
5.4.160.1030.03719.18
5.4.150.0200.04318.82
5.4.140.0300.03316.54
5.4.130.0300.05016.55
5.4.120.0270.03716.34
5.4.110.0330.03016.41
5.4.100.0330.03016.50
5.4.90.0300.04016.59
5.4.80.0270.03716.43
5.4.70.0300.03316.43
5.4.60.0270.04016.51
5.4.50.0430.04016.51
5.4.40.0200.04316.42
5.4.30.0330.03016.17
5.4.20.0270.04316.42
5.4.10.0300.03016.42
5.4.00.0300.03715.98
5.3.290.0270.04314.65
5.3.280.0300.03714.73
5.3.270.0300.04014.70
5.3.260.0230.04014.52
5.3.250.0370.04014.54
5.3.240.0330.04014.54
5.3.230.0270.03714.51
5.3.220.0300.05314.64
5.3.210.0330.04714.59
5.3.200.0330.04714.80
5.3.190.0470.03714.59
5.3.180.0400.05714.48
5.3.170.0370.04714.48
5.3.160.0300.05014.82
5.3.150.0500.06314.49
5.3.140.0430.03314.63
5.3.130.0330.04014.48
5.3.120.0370.04014.57
5.3.110.0470.03314.55
5.3.100.0400.07013.98
5.3.90.0400.03713.94
5.3.80.0400.05714.26
5.3.70.0430.05714.12
5.3.60.0300.04713.93
5.3.50.0330.03713.88
5.3.40.0370.07013.88
5.3.30.0330.03713.86
5.3.20.0500.05713.63
5.3.10.0270.04313.79
5.3.00.0330.03313.56
5.2.170.0300.02712.01
5.2.160.0270.02712.01
5.2.150.0330.02312.01
5.2.140.0330.03712.01
5.2.130.0230.03012.01
5.2.120.0330.03012.01
5.2.110.0270.02312.01
5.2.100.0270.03312.01
5.2.90.0270.02312.01
5.2.80.0170.03312.01
5.2.70.0270.04012.01
5.2.60.0230.04312.01
5.2.50.0300.03312.01
5.2.40.0230.03012.01
5.2.30.0270.02312.01
5.2.20.0270.03012.01
5.2.10.0300.06712.01
5.2.00.0300.05712.01
5.1.60.0300.04312.01
5.1.50.0300.03712.01
5.1.40.0300.02712.01
5.1.30.0330.04312.01
5.1.20.0300.03312.01
5.1.10.0270.05312.01
5.1.00.0230.04312.01
5.0.50.0100.02012.01
5.0.40.0170.04312.01
5.0.30.0100.03312.01
5.0.20.0170.03012.01
5.0.10.0130.04012.01
5.0.00.0130.04012.01
4.4.90.0130.02312.01
4.4.80.0170.01012.01
4.4.70.0070.01712.01
4.4.60.0070.01712.01
4.4.50.0130.01312.01
4.4.40.0170.04312.01
4.4.30.0070.02012.01
4.4.20.0100.02712.01
4.4.10.0100.01712.01
4.4.00.0130.02012.01
4.3.110.0030.02012.01
4.3.100.0100.01712.01
4.3.90.0100.01712.01
4.3.80.0100.02312.01
4.3.70.0070.02012.01
4.3.60.0070.01712.01
4.3.50.0070.02012.01
4.3.40.0130.02712.01
4.3.30.0070.02012.01
4.3.20.0070.03012.01
4.3.10.0100.02312.01
4.3.00.0100.03312.01

preferences:
58.53 ms | 401 KiB | 5 Q