3v4l.org

run code in 300+ PHP versions simultaneously
<?php $twitter_handle = "twitter"; function buildBaseString($baseURI, $method, $params) { $r = array(); ksort($params); foreach($params as $key=>$value){ $r[] = "$key=" . rawurlencode($value); } return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r)); } function buildAuthorizationHeader($oauth) { $r = 'Authorization: OAuth '; $values = array(); foreach($oauth as $key=>$value) $values[] = "$key=\"" . rawurlencode($value) . "\""; $r .= implode(', ', $values); return $r; } $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $oauth_access_token = "your own"; $oauth_access_token_secret = "your own"; $consumer_key = "your own"; $consumer_secret = "your own"; $oauth = array( 'oauth_consumer_key' => $consumer_key, 'oauth_nonce' => time(), 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_token' => $oauth_access_token, 'oauth_timestamp' => time(), 'oauth_version' => '1.0', 'screen_name' => $twitter_handle); $base_info = buildBaseString($url, 'GET', $oauth); $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret); $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true)); $oauth['oauth_signature'] = $oauth_signature; // Make Requests $header = array(buildAuthorizationHeader($oauth), 'Content-Type: application/json', 'Expect:'); $options = array( CURLOPT_HTTPHEADER => $header, //CURLOPT_POSTFIELDS => $postfields, CURLOPT_HEADER => false, CURLOPT_URL => $url . '?screen_name=' . $twitter_handle, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false); $feed = curl_init(); curl_setopt_array($feed, $options); $json = curl_exec($feed); curl_close($feed); $decode = json_decode($json, true); //getting the file content as array echo '<ul>'; foreach($decode as $tweet) { $tweet_text = $tweet["text"]; echo '<li>'; echo $tweet_text; echo '</li>'; } echo '</ul>'; $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $reg_exHash = "/#([a-z_0-9]+)/i"; $reg_exUser = "/@([a-z_0-9]+)/i"; echo '<ul>'; foreach ($decode as $tweet) { $tweet_text = $tweet["text"]; //get the tweet // make links link to URL // http://css-tricks.com/snippets/php/find-urls-in-text-make-links/ if(preg_match($reg_exUrl, $tweet_text, $url)) { // make the urls hyper links $tweet_text = preg_replace($reg_exUrl, "<a href='{$url[0]}'>{$url[0]}</a> ", $tweet_text); } if(preg_match($reg_exHash, $tweet_text, $hash)) { // make the hash tags hyper links https://twitter.com/search?q=%23truth $tweet_text = preg_replace($reg_exHash, "<a href='https://twitter.com/search?q={$hash[0]}'>{$hash[0]}</a> ", $tweet_text); // swap out the # in the URL to make %23 $tweet_text = str_replace("/search?q=#", "/search?q=%23", $tweet_text ); } if(preg_match($reg_exUser, $tweet_text, $user)) { $tweet_text = preg_replace("/@([a-z_0-9]+)/i", "<a href='http://twitter.com/$1'>$0</a>", $tweet_text); } // display each tweet in a list item echo "<li>" . $tweet_text . "</li>"; } echo '</ul>'; ?>

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)
7.2.60.0040.01216.94
7.1.200.0000.01315.79
7.1.70.0030.00617.26
7.1.60.0110.01519.46
7.1.50.0150.00917.05
7.1.00.0000.08022.38
7.0.200.0660.00714.96
7.0.140.0100.05022.12
7.0.90.0300.07021.78
7.0.80.0030.08321.89
7.0.70.0070.08321.91
7.0.60.0030.08721.73
7.0.50.0000.08322.16
7.0.40.0030.07019.95
7.0.30.0000.04720.19
7.0.20.0030.08320.15
7.0.10.0130.07020.13
7.0.00.0130.08020.12
5.6.280.0000.07720.85
5.6.240.0100.06720.63
5.6.230.0100.07720.65
5.6.220.0030.09720.69
5.6.210.0130.08020.60
5.6.200.0030.07721.11
5.6.190.0030.05721.03
5.6.180.0100.06321.16
5.6.170.0030.05321.20
5.6.160.0000.09321.13
5.6.150.0170.06721.10
5.6.140.0070.04721.15
5.6.130.0030.05321.11
5.6.120.0130.04321.10
5.6.110.0100.08021.13
5.6.100.0130.03721.05
5.6.90.0100.08321.03
5.6.80.0070.08320.58
5.6.70.0000.08320.46
5.6.60.0070.07020.34
5.6.50.0170.07320.35
5.6.40.0130.07720.34
5.6.30.0100.07720.42
5.6.20.0030.08320.42
5.6.10.0070.04720.51
5.6.00.0130.07020.48
5.5.380.0000.08720.43
5.5.370.0070.08720.43
5.5.360.0100.07320.48
5.5.350.0030.08720.52
5.5.340.0100.04320.79
5.5.330.0070.08020.81
5.5.320.0030.07720.77
5.5.310.0000.07020.94
5.5.300.0070.06720.64
5.5.290.0130.07720.90
5.5.280.0100.07020.86
5.5.270.0070.08720.95
5.5.260.0130.07720.88
5.5.250.0030.09020.77
5.5.240.0170.07020.21
5.5.230.0100.06720.20
5.5.220.0100.04320.32
5.5.210.0100.08020.03
5.5.200.0070.06720.10
5.5.190.0170.07720.20
5.5.180.0130.04020.11
5.5.160.0070.04720.30
5.5.150.0100.04720.25
5.5.140.0030.08320.29
5.5.130.0070.04720.29
5.5.120.0100.05720.18
5.5.110.0070.07720.14
5.5.100.0070.04320.07
5.5.90.0100.05319.98
5.5.80.0070.08020.12
5.5.70.0070.04320.09
5.5.60.0100.07720.13
5.5.50.0070.07720.09
5.5.40.0130.07020.03
5.5.30.0100.05720.08
5.5.20.0130.08320.04
5.5.10.0070.06020.07
5.5.00.0130.08320.16
5.4.450.0200.04719.37
5.4.440.0100.07319.37
5.4.430.0130.05719.48
5.4.420.0000.09319.27
5.4.410.0070.08019.32
5.4.400.0100.07319.13
5.4.390.0070.07719.02
5.4.380.0070.07318.87
5.4.370.0070.08319.09
5.4.360.0170.06019.16
5.4.350.0000.08018.88
5.4.340.0070.07719.13
5.4.320.0100.05718.94
5.4.310.0030.08019.12
5.4.300.0030.07719.16
5.4.290.0030.07318.87
5.4.280.0070.07318.90
5.4.270.0130.03718.87
5.4.260.0100.04019.13
5.4.250.0070.06018.89
5.4.240.0100.07319.12
5.4.230.0100.06319.13
5.4.220.0000.08019.18
5.4.210.0030.07718.87
5.4.200.0070.06719.17
5.4.190.0070.07719.11
5.4.180.0100.07019.22
5.4.170.0070.07719.02
5.4.160.0030.05019.16
5.4.150.0070.07318.88
5.4.140.0130.06016.46
5.4.130.0100.07016.52
5.4.120.0030.06716.50
5.4.110.0030.07316.40
5.4.100.0100.07316.56
5.4.90.0230.06016.48
5.4.80.0070.06016.51
5.4.70.0070.07316.39
5.4.60.0030.05316.38
5.4.50.0070.04716.47
5.4.40.0100.06316.46
5.4.30.0100.04016.37
5.4.20.0030.04316.42
5.4.10.0070.07016.39
5.4.00.0000.04015.86
5.3.290.0070.05314.76
5.3.280.0070.08014.68
5.3.270.0030.06714.75
5.3.260.0130.05714.61
5.3.250.0130.07014.72
5.3.240.0130.07014.70
5.3.230.0100.07014.61
5.3.220.0130.05314.66
5.3.210.0130.06714.65
5.3.200.0030.05314.66
5.3.190.0070.08014.68
5.3.180.0070.07314.60
5.3.170.0130.07314.58
5.3.160.0130.07714.62
5.3.150.0130.07014.52
5.3.140.0070.03714.72
5.3.130.0070.03714.55
5.3.120.0100.04314.68
5.3.110.0100.06314.66
5.3.100.0070.08314.07
5.3.90.0100.07014.18
5.3.80.0030.07714.04
5.3.70.0030.07014.10
5.3.60.0070.07314.08
5.3.50.0070.04013.86
5.3.40.0070.06714.00
5.3.30.0070.03714.00
5.3.20.0130.06313.84
5.3.10.0130.05313.62
5.3.00.0070.07713.75
5.2.170.0030.06711.29
5.2.160.0100.05011.29
5.2.150.0030.04711.23
5.2.140.0100.05311.20
5.2.130.0070.06011.22
5.2.120.0100.03011.12
5.2.110.0070.06011.25
5.2.100.0130.05311.12
5.2.90.0070.06011.04
5.2.80.0000.05711.16
5.2.70.0070.06011.23
5.2.60.0000.04311.20
5.2.50.0170.05011.05
5.2.40.0070.05310.91
5.2.30.0070.05711.01
5.2.20.0070.06010.91
5.2.10.0030.05310.96
5.2.00.0030.06310.68
5.1.60.0000.05710.24
5.1.50.0000.05310.24
5.1.40.0030.05710.24
5.1.30.0030.04010.39
5.1.20.0030.05710.30
5.1.10.0000.03310.24
5.1.00.0070.05010.24
5.0.50.0070.04710.24
5.0.40.0070.03010.24
5.0.30.0100.05710.24
5.0.20.0030.04310.24
5.0.10.0070.03010.24
5.0.00.0100.05010.24
4.4.90.0030.03310.24
4.4.80.0030.03310.24
4.4.70.0000.04010.24
4.4.60.0070.03010.24
4.4.50.0000.03710.24
4.4.40.0030.03010.24
4.4.30.0030.02010.24
4.4.20.0000.04010.24
4.4.10.0070.03310.24
4.4.00.0030.05310.24
4.3.110.0030.03310.24
4.3.100.0000.02010.24
4.3.90.0070.03010.24
4.3.80.0030.05710.24
4.3.70.0030.02710.24
4.3.60.0000.03710.24
4.3.50.0030.02010.24
4.3.40.0100.05010.24
4.3.30.0030.01310.24
4.3.20.0000.03710.24
4.3.10.0000.03010.24
4.3.00.0000.02010.24

preferences:
41.81 ms | 401 KiB | 5 Q