3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Weather Scraper // Fetch the page for the city $contents = file_get_contents('http://www.weather-forecast.com/locations/Bend/forecasts/latest'); // Extract the 3 day Weather // The following pattern will yeild forecast in $matches[1] as of September 10, 2015 in the U.S.A. // However the multiple <span> blocks may possibly change causing this logic to fail in the future. $pattern = '/3 Day Weather Forecast Summary:<\/b><span class="read-more-small"><span class="read-more-content"> <span class="phrase">(.*?)</s'; preg_match( $pattern, $contents, $matches); $forecast1 = $matches[1]; // Instead, let's take a hopefully more robust approach and extract the forecast from $matches[0] using a less <span> intensive pattern // Note 1: We separately keep track of the search prefix, so we can remove this from the beginning of $matches[0]. // Note 2: We end the search on pattern not with '<', but with '<\/span' because we need to make sure we search to the first closing </span> $patternPrefix = '3 Day Weather Forecast Summary:'; $pattern = '/' . $patternPrefix . '(.*?)<\/span/s'; preg_match( $pattern, $contents, $matches); // $matches[0] starts with the $patternPrefix, so remove that from the beginning. $forecast2 = trim( substr($matches[0], strlen($patternPrefix)) ); echo $forecast1; echo $forecast2;

Here you find the average performance (time & memory) of each version. A greyed 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.00.0060.00619.82
7.1.100.0000.01318.80
7.1.70.0050.00317.29
7.1.60.0210.00420.03
7.1.50.0000.01517.57
7.1.00.0030.07722.64
7.0.200.0200.00815.41
7.0.60.0030.04020.28
7.0.50.0100.07718.18
7.0.40.0130.07720.57
7.0.30.0500.07020.59
7.0.20.0300.07020.54
7.0.10.0100.07320.48
7.0.00.0030.09020.55
5.6.280.0070.03021.27
5.6.210.0200.07020.96
5.6.200.0100.05318.66
5.6.190.0130.03720.96
5.6.180.0230.09021.06
5.6.170.0300.05320.82
5.6.160.0070.03720.78
5.6.150.0130.08018.55
5.6.140.0030.08318.55
5.6.130.0070.04718.43
5.6.120.0070.04321.42
5.6.110.0070.08321.49
5.6.100.0100.06321.41
5.6.90.0070.04721.51
5.6.80.0070.06020.77
5.6.70.3370.03320.88
5.5.350.0300.07020.77
5.5.340.0070.08018.29
5.5.330.0030.07720.79
5.5.320.0300.07720.58
5.5.310.0300.08720.62
5.5.300.0000.04718.34
5.5.290.0100.04018.34
5.5.280.0000.09021.21
5.5.270.0170.07321.08
5.5.260.0130.03021.24
5.5.250.0200.06320.90
5.5.240.0370.06320.61
5.4.450.0100.06319.75
5.4.440.0200.05719.68
5.4.430.0200.05319.67
5.4.420.0230.04719.76
5.4.410.0170.05319.46
5.4.400.0330.06019.42
5.4.390.0270.05719.42
5.4.380.0230.04719.46
5.4.370.0170.05319.42
5.4.360.0130.05719.44
5.4.350.0230.04719.48
5.4.340.0100.06019.43
5.4.320.0100.06319.23
5.4.310.0170.05319.35
5.4.300.0130.06019.47
5.4.290.0230.04319.47
5.4.280.0330.04719.27
5.4.270.0170.05019.19
5.4.260.0230.05719.48
5.4.250.0130.05719.52
5.4.240.0130.06319.41
5.4.230.0100.06019.34
5.4.220.0200.05019.43
5.4.210.0170.05319.30
5.4.200.0270.04017.12
5.4.190.0170.05319.26
5.4.180.0270.04319.30
5.4.170.0100.06019.51
5.4.160.0130.06319.43
5.4.150.0170.05719.41
5.4.140.0170.05016.79
5.4.130.0170.04716.61
5.4.120.0170.04716.79
5.4.110.0270.04316.64
5.4.100.0170.05016.65
5.4.90.0270.04016.62
5.4.80.0200.04316.73
5.4.70.0300.05716.90
5.4.60.0030.07017.00
5.4.50.0070.07317.05
5.4.40.0170.04017.00
5.4.30.0330.06017.01
5.4.20.0400.05316.90
5.3.290.1030.03314.69
5.3.280.1230.04014.77
5.3.270.0230.03714.86
5.3.260.1200.04314.69
5.3.250.0800.04314.65
5.3.240.0870.04014.63
5.3.230.0670.02714.85
5.3.220.0570.04014.82
5.3.210.0530.04014.74
5.3.200.0430.04014.63
5.3.190.0800.03314.52
5.3.180.0900.03314.82
5.3.170.0970.02014.63