3v4l.org

run code in 300+ PHP versions simultaneously
<?php class App { function run() { // Prerequisites. class system_tags { function __call($name, $params) { return 'TAG ' . $name; } } $system_tags = new system_tags(); $code = new \stdClass(); $code->tags = [ 'hello' => 'HELLO', 'world' => 'WORLD', ]; $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withStrReplace($code, $system_tags); $this->template = 'Blah blah {hello} blah blah {world}.'; $this->withRegexReplaceCallback($code, $system_tags); } function withStrReplace($code, $system_tags) { foreach($core->tags as $tag_name => $tag_method) { $this->template = str_replace( '{' . $tag_name . '}', $system_tags->{$tag_method}(), $this->template ); } } function withRegexReplaceCallback($code, $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>"; } }

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)
5.6.80.0130.07320.42
5.6.70.0070.07720.52
5.5.240.0230.02320.24
5.4.400.0170.07318.73
5.4.390.0300.04718.77
5.4.380.0130.06318.75
5.4.370.0230.05718.75
5.4.360.0170.06018.73
5.4.350.0170.06018.83
5.4.340.0200.05318.78
5.4.320.0230.05718.61
5.4.310.0330.04018.83
5.4.300.0130.06018.69
5.4.290.0230.04718.83
5.4.280.0270.05018.72
5.4.270.0200.05318.71
5.4.260.0200.05318.74
5.4.250.0170.05718.51
5.4.240.0230.05318.59
5.4.230.0330.04718.61
5.4.220.0170.06018.61
5.4.210.0230.05018.74
5.4.200.0200.05016.54
5.4.190.0400.04718.50
5.4.180.0170.05318.71
5.4.170.0270.05318.75
5.4.160.0230.05318.70
5.4.150.0270.05018.47
5.4.140.0130.06716.42
5.4.130.0130.07316.28
5.4.120.0270.05016.31
5.4.110.0270.05016.34
5.4.100.0130.07316.18
5.4.90.0270.05316.29
5.4.80.0230.04716.30
5.4.70.0170.05716.39
5.4.60.0270.05316.30
5.4.50.0200.04716.30
5.4.40.0230.04716.39
5.4.30.0230.04716.24
5.4.20.0170.06316.39
5.4.10.0230.05316.25
5.4.00.0200.05015.64
5.3.290.0230.05014.86
5.3.280.0130.05714.70
5.3.270.0170.06014.58
5.3.260.0300.04714.74
5.3.250.0230.04714.70
5.3.240.0270.07014.63
5.3.230.0170.06014.59
5.3.220.0270.06714.73
5.3.210.0200.06014.68
5.3.200.0300.05314.75
5.3.190.0130.05714.56
5.3.180.0130.05714.66
5.3.170.0230.04314.58
5.3.160.0170.05314.59
5.3.150.0370.05714.72
5.3.140.0200.05714.69
5.3.130.0170.05714.75
5.3.120.0130.06714.56
5.3.110.0200.05314.64
5.3.100.0270.04314.08
5.3.90.0100.06014.02
5.3.80.0170.05014.04
5.3.70.0200.05314.05
5.3.60.0230.05314.12
5.3.50.0270.04314.10
5.3.40.0230.04714.00
5.3.30.0200.04714.11
5.3.20.0130.06713.90
5.3.10.0230.04713.75
5.3.00.0330.03713.75
5.2.170.0130.04311.25
5.2.160.0070.05311.26
5.2.150.0200.05311.25
5.2.140.0130.04311.16
5.2.130.0030.05011.11
5.2.120.0170.04011.21
5.2.110.0130.04011.22
5.2.100.0130.04011.13
5.2.90.0170.03711.08
5.2.80.0170.04011.11
5.2.70.0100.04711.07
5.2.60.0170.04011.03
5.2.50.0170.05011.01
5.2.40.0200.04711.21
5.2.30.0100.04310.98
5.2.20.0130.04310.98
5.2.10.0200.03710.85
5.2.00.0170.04310.82
5.1.60.0100.03710.12
5.1.50.0130.03710.18
5.1.40.0170.03710.15
5.1.30.0070.04310.39
5.1.20.0130.04010.38
5.1.10.0100.04310.05
5.1.00.0100.04010.26
5.0.50.0070.0308.58
5.0.40.0070.0278.45
5.0.30.0100.0578.32
5.0.20.0070.0408.18
5.0.10.0030.0338.20
5.0.00.0130.0408.37
4.4.90.0030.0275.96
4.4.80.0030.0275.96
4.4.70.0070.0235.87
4.4.60.0070.0275.93
4.4.50.0070.0235.88
4.4.40.0000.0405.99
4.4.30.0100.0205.90
4.4.20.0100.0205.96
4.4.10.0070.0236.07
4.4.00.0130.0376.04
4.3.110.0070.0235.85
4.3.100.0130.0175.80
4.3.90.0030.0275.82
4.3.80.0100.0375.86
4.3.70.0130.0175.83
4.3.60.0100.0175.92
4.3.50.0100.0205.77
4.3.40.0070.0335.86
4.3.30.0030.0304.55
4.3.20.0070.0204.64
4.3.10.0030.0234.51
4.3.00.0070.0237.32

preferences:
141.69 ms | 1394 KiB | 7 Q