3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Developed by TheNaked. Do not resell this script. */ set_time_limit(0); class StrawPoll { public function __construct() { } public function vote($id, array $votes, $amount = 10, $proxyList = null, $timeout = 5, $showErrors = true) { $mh = curl_multi_init(); $chs = array(); if(is_file($proxyList)) { $parts = pathinfo($proxyList); $json = false; if($parts['extension'] == 'json') { $proxies = json_decode(file_get_contents($proxyList), true); if($proxies) { $json = true; } else { return 'Malformed JSON in ' . $proxyList; } } else { $proxies = file($proxyList); } } $post = array( 'id' => $id, 'votes' => $votes ); $post = http_build_query($post); $headers = array( 'Origin: http://strawpoll.me', 'If-None-Match: 6bbfd', 'X-Requested-With: XMLHttpRequest' ); $loop = false; if($amount == -1) { $loop = true; $amount = 25; } if(isset($proxies)) { $amount = count($proxies); } $used = array(); for($i = 0; $i < $amount; $i++) { $ch = $this->makeCurl('http://strawpoll.me/ajax/vote'); $chs[] = $ch; if(isset($proxies)) { if(count($proxies) < 1) { if($showErrors) { echo 'Out of proxies :(' . PHP_EOL; } break; } $key = array_rand($proxies); $proxy = $proxies[$key]; unset($proxies[$key]); $proxyType = CURLPROXY_HTTP; if(!$json) { $proxy = trim($proxy); $parts = explode(':', $proxy); if(isset($parts[0], $parts[1])) { $proxyIP = $parts[0]; $proxyPort = $parts[1]; } else { $i--; continue; } if(isset($parts[2])) { $proxyType = strtoupper($proxyType) == 'SOCKS5' ? CURLPROXY_SOCKS5 : CURLPROXY_HTTP; } } else if($json && isset($proxy['ip'], $proxy['port'])) { $proxyIP = $proxy['ip']; $proxyPort = $proxy['port']; if(isset($proxy['type'])) { $proxyType = strtoupper($proxy['type']) == 'SOCKS5' ? CURLPROXY_SOCKS5 : CURLPROXY_HTTP; } } if(isset($used[$proxyIP])) { $i--; continue; } $used[$proxyIP] = true; if(!filter_var($proxyIP, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) || (!ctype_digit($proxyPort) || ($proxyPort < 0 || $proxyPort > 65535))) { $i--; continue; } curl_setopt_array($ch, array( CURLOPT_PROXY => $proxyIP . ':' . $proxyPort, CURLOPT_PROXYTYPE => $proxyType )); } curl_setopt_array($ch, array( CURLOPT_POSTFIELDS => $post, CURLOPT_POST => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_REFERER => 'http://strawpoll.me/' . $id, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36', CURLOPT_TIMEOUT => $timeout )); curl_multi_add_handle($mh, $ch); } $running = null; $votes = 0; $j = 0; $results = array(); do { while(($exec = curl_multi_exec($mh, $running)) == CURLM_CALL_MULTI_PERFORM); if($exec != CURLM_OK) { break; } while($ch = curl_multi_info_read($mh)) { $j++; $ch = $ch['handle']; $error = curl_error($ch); if(!$error) { $resp = curl_multi_getcontent($ch); $out = json_decode($resp, true); if(!isset($out['success'])) { if($showErrors) { echo 'Didn\'t vote. Invalid response.' . PHP_EOL; var_dump($resp); } } else { if($out['success'] == true) { $votes++; echo '[' . $votes . '] Voted' . PHP_EOL; } } $results[] = $out; } else { $results[] = $error; if($showErrors) { echo $error . PHP_EOL; } } curl_multi_remove_handle($mh, $ch); curl_close($ch); } } while($running); curl_multi_close($mh); if($loop) { $this->vote($id, $votes, $amount, $proxyList, $timeout); return array('results' => $results, 'votes' => $votes); } return array('results' => $results, 'votes' => $votes, 'total' => $amount); } public function makeCurl($url) { $cookie = dirname(__FILE__) . '/strawpoll.txt'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie )); return $ch; } } if(isset($_GET['key']) == "hnbu43rhb453bh435bhchhb43bh4") { $sp = new StrawPoll(); $votes = $sp->vote($_GET["id"], array($_GET["voteid"]), 2, 'proxies.txt', 30, false); echo 'Successfully voted ' . $votes['votes'] . '/' . $votes['total'] . ' time(s)'; } else { echo "wrong key"; } ?>

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.3.10.0080.00316.09
7.3.00.0070.00716.03
7.2.130.0100.00616.62
7.2.120.0090.00616.73
7.2.110.0070.01016.52
7.2.100.0100.00316.34
7.2.90.0060.00616.63
7.2.80.0070.00716.51
7.2.70.0060.00616.81
7.2.60.0060.01016.29
7.2.50.0070.01016.55
7.2.40.0030.00616.33
7.2.30.0030.00616.50
7.2.20.0060.00316.75
7.2.10.0040.00716.26
7.2.00.0130.01016.41
7.1.250.0060.00615.36
7.1.70.0000.00716.74
7.1.60.0040.01919.32
7.1.50.0050.00916.73
7.1.00.0000.08022.50
7.0.200.0000.00816.61
7.0.140.0030.07321.92
7.0.100.0170.07320.09
7.0.90.0100.08720.09
7.0.80.0100.07719.95
7.0.70.0070.08720.07
7.0.60.0030.05020.00
7.0.50.0170.07720.41
7.0.40.0100.07320.11
7.0.30.0070.08320.04
7.0.20.0100.03720.08
7.0.10.0070.04720.03
7.0.00.0000.05020.07
5.6.280.0030.07321.16
5.6.250.0130.07320.82
5.6.240.0130.07720.66
5.6.230.0170.04320.73
5.6.220.0100.07720.73
5.6.210.0070.08320.74
5.6.200.0070.05021.09
5.6.190.0100.08321.06
5.6.180.0130.07321.10
5.6.170.0000.06721.10
5.6.160.0070.05721.14
5.6.150.0100.06321.01
5.6.140.0030.04320.98
5.6.130.0030.04721.13
5.6.120.0130.06021.16
5.6.110.0100.05721.05
5.6.100.0070.04020.97
5.6.90.0100.05021.17
5.6.80.0130.07720.61
5.6.70.0100.03020.41
5.6.60.0000.06720.38
5.6.50.0070.04020.43
5.6.40.0000.04320.44
5.6.30.0000.04320.41
5.6.20.0070.03720.44
5.6.10.0070.04320.52
5.6.00.0100.03320.36
5.5.380.0070.08320.49
5.5.370.0070.08320.52
5.5.360.0030.05720.54
5.5.350.0100.06720.39
5.5.340.0100.07720.84
5.5.330.0200.05720.99
5.5.320.0100.08020.82
5.5.310.0200.03320.86
5.5.300.0130.04320.84
5.5.290.0070.04020.93
5.5.280.0030.04320.86
5.5.270.0070.04020.98
5.5.260.0070.04020.82
5.5.250.0000.04020.69
5.5.240.0070.04020.37
5.5.230.0030.04320.29
5.5.220.0000.04020.21
5.5.210.0000.04320.04
5.5.200.0130.03020.20
5.5.190.0000.04020.29
5.5.180.0030.04020.24
5.5.160.0030.04020.21
5.5.150.0030.06020.33
5.5.140.0000.03720.27
5.5.130.0000.04320.14
5.5.120.0030.04320.32
5.5.110.0070.03720.15
5.5.100.0030.03720.16
5.5.90.0100.03320.16
5.5.80.0130.03020.15
5.5.70.0170.02720.09
5.5.60.0070.03020.21
5.5.50.0070.03720.20
5.5.40.0000.04320.11
5.5.30.0100.02720.20
5.5.20.0070.05720.13
5.5.10.0030.04020.09
5.5.00.0070.07720.13
5.4.450.0030.04019.38
5.4.440.0030.04019.45
5.4.430.0030.04019.53
5.4.420.0130.03719.46
5.4.410.0000.03719.34
5.4.400.0030.04018.82
5.4.390.0000.04718.95
5.4.380.0030.03719.16
5.4.370.0070.03319.13
5.4.360.0070.03019.23
5.4.350.0130.02719.12
5.4.340.0030.03718.88
5.4.320.0100.03318.90
5.4.310.0000.04019.05
5.4.300.0000.04319.13
5.4.290.0070.03319.20
5.4.280.0070.03719.04
5.4.270.0070.03718.85
5.4.260.0030.03719.00
5.4.250.0130.02718.90
5.4.240.0030.03719.17
5.4.230.0030.03719.12
5.4.220.0070.03719.12
5.4.210.0070.03319.18
5.4.200.0000.08319.04
5.4.190.0000.04019.00
5.4.180.0000.04019.02
5.4.170.0100.05018.86
5.4.160.0070.07319.21
5.4.150.0030.08019.08
5.4.140.0030.04316.39
5.4.130.0170.06316.48
5.4.120.0130.07016.46
5.4.110.0030.07716.52
5.4.100.0070.07316.48
5.4.90.0030.08016.49
5.4.80.0200.05716.46
5.4.70.0100.06716.50
5.4.60.0030.07316.54
5.4.50.0100.06016.42
5.4.40.0030.07316.54
5.4.30.0070.05316.39
5.4.20.0070.06016.37
5.4.10.0130.06016.41
5.4.00.0030.08016.00

preferences:
39.01 ms | 400 KiB | 5 Q