3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); ini_set('display_errors', 1); class system_tags { function __call($name, $params) { return 'TAG "' . $name . '" WAS HERE'; } } class App { function run() { // Prerequisites. $system_tags = new system_tags(); $core = new \stdClass(); $core->tags = array( 'hello' => 'HELLO!', 'world' => 'WORLD!', ); $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 ); } } 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<br>"; } } $app = new App(); $app->run();
based on aT2IU

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0100.00317.20
7.2.00.0040.00719.50
7.1.200.0060.01015.99
7.1.100.0080.00818.42
7.1.70.0000.00817.46
7.1.60.0030.01719.50
7.1.50.0110.01117.24
7.1.00.0030.07722.32
7.0.200.0160.00314.96
7.0.140.0070.07321.92
7.0.60.0000.08719.95
7.0.50.0030.04317.75
7.0.40.0070.09320.03
7.0.30.0270.08320.07
7.0.20.0300.06720.24
7.0.10.0230.06720.11
7.0.00.0070.05320.16
5.6.210.0100.05720.65
5.6.200.0100.05318.16
5.6.190.0100.08320.41
5.6.180.0400.07320.53
5.6.170.0300.06320.50
5.6.160.0030.04320.57
5.6.150.0030.05018.21
5.6.140.0070.08018.27
5.6.130.0030.05018.15
5.6.120.0030.08321.06
5.6.110.0100.08720.97
5.6.100.0130.07320.98
5.6.90.0030.04721.11
5.6.80.0070.08320.39
5.6.70.0200.07720.47
5.5.350.0170.07320.46
5.5.340.0070.03717.98
5.5.330.0100.06720.26
5.5.320.0070.04020.28
5.5.310.0330.07720.35
5.5.300.0070.06717.96
5.5.290.0070.04717.93
5.5.280.0000.04320.79
5.5.270.0230.04020.66
5.5.260.0070.06720.75
5.5.250.0070.08320.71
5.5.240.0100.06320.29
5.4.450.0600.05319.61
5.4.440.0870.06719.47
5.4.430.0930.05319.46
5.4.420.0030.05719.19
5.4.410.0900.05319.45
5.4.400.0230.04718.51
5.4.390.0170.05318.75
5.4.380.0230.05018.73
5.4.370.0300.05318.57
5.4.360.0130.07318.73
5.4.350.0170.06018.51
5.4.340.0230.06018.78
5.4.320.0270.07018.71
5.4.310.0300.06018.73
5.4.300.0230.05318.57
5.4.290.0370.04318.71
5.4.280.0130.05718.53
5.4.270.0130.06318.74
5.4.260.0170.05718.82
5.4.250.0200.05718.73
5.4.240.0330.04718.75
5.4.230.0130.06318.57
5.4.220.0270.05018.47
5.4.210.0270.06318.71
5.4.200.0270.04716.63
5.4.190.0300.04718.52
5.4.180.0200.05718.52
5.4.170.0200.05718.70
5.4.160.0300.05018.71
5.4.150.0130.06318.69
5.4.140.0130.06016.45
5.4.130.0130.05716.18
5.4.120.0070.06716.45
5.4.110.0130.06016.20
5.4.100.0230.05016.30
5.4.90.0170.05716.29
5.4.80.0200.05316.23
5.4.70.0270.05016.27
5.4.60.0330.05716.28
5.4.50.0130.05716.30
5.4.40.0130.05716.32
5.4.30.0230.04716.30
5.4.20.0130.06016.43
5.4.10.0130.05716.17
5.4.00.0070.06315.78
5.3.290.0130.07314.84
5.3.280.0200.05014.60
5.3.270.0200.05314.66
5.3.260.0230.04714.70
5.3.250.0200.05014.63
5.3.240.0200.05014.91
5.3.230.0330.04014.74
5.3.220.0330.04314.78
5.3.210.0170.06014.61
5.3.200.0200.05014.63
5.3.190.0270.05714.56
5.3.180.0230.05014.68
5.3.170.0230.05714.75
5.3.160.0130.06014.77
5.3.150.0070.06714.86
5.3.140.0170.05314.66
5.3.130.0300.06714.73
5.3.120.0230.07014.75
5.3.110.0100.08314.84
5.3.100.0300.06314.10
5.3.90.0130.05314.16
5.3.80.0270.06314.07
5.3.70.0300.06014.12
5.3.60.0200.05014.13
5.3.50.0130.05313.95
5.3.40.0270.04714.00
5.3.30.0270.04314.21
5.3.20.0230.05013.82
5.3.10.0300.06013.65
5.3.00.0230.06713.76
5.2.170.0230.04311.27
5.2.160.0300.04311.23
5.2.150.0130.05011.28
5.2.140.0230.04011.21
5.2.130.0170.04311.24
5.2.120.0200.04011.24
5.2.110.0230.04711.15
5.2.100.0230.03711.23
5.2.90.0130.04311.34
5.2.80.0130.04711.23
5.2.70.0100.05011.21
5.2.60.0270.03311.14
5.2.50.0130.04311.11
5.2.40.0100.04311.00
5.2.30.0170.04011.00
5.2.20.0030.05011.00
5.2.10.0100.04310.92
5.2.00.0200.03710.76
5.1.60.0100.03710.19
5.1.50.0170.03010.13
5.1.40.0170.03010.20
5.1.30.0170.04710.40
5.1.20.0170.04010.60
5.1.10.0130.03310.08
5.1.00.0070.04310.13
5.0.50.0070.0308.59
5.0.40.0030.0338.55
5.0.30.0100.0438.42
5.0.20.0100.0278.43
5.0.10.0070.0308.33
5.0.00.0000.0508.23
4.4.90.0000.0275.94
4.4.80.0070.0235.98
4.4.70.0070.0205.95
4.4.60.0100.0175.93
4.4.50.0130.0175.94
4.4.40.0030.0375.90
4.4.30.0070.0235.93
4.4.20.0000.0336.00
4.4.10.0030.0335.95
4.4.00.0100.0335.97
4.3.110.0100.0205.85
4.3.100.0070.0235.85
4.3.90.0070.0205.82
4.3.80.0100.0335.83
4.3.70.0100.0175.94
4.3.60.0130.0175.81
4.3.50.0070.0235.81
4.3.40.0100.0375.80
4.3.30.0100.0204.57
4.3.20.0000.0234.58
4.3.10.0070.0234.55
4.3.00.0170.0177.32