3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("BF3APIIdent", 'R8tyRf7J5O'); define("BF3APIKey", 'UvVGtyTwb1BlT7nA2dzFT8fKIdUgeksg'); // Platform can be pc, 360, ps3 $platform = 'pc'; $memberObj = new \app\classes\Members(); $queryParam = array( 'WHERE' => "WHERE (usertype_tbusers<>'N')", 'ORDER' => 'ORDER BY lastupdate_tbusers ASC', 'LIMIT' => 'LIMIT ' . 20 ); $results = $memberObj->getAllbyCriteria($queryParam); $tempData = array('players' => array(), 'opt' => array()); foreach ($results as $newsEntry): $bf3Stats = updatePlayer($platform, $newsEntry->userid_tbusers); if ($bf3Stats['status'] == "exists"): $bf3Stats = lookupPlayer($platform, $newsEntry->userid_tbusers); if ($bf3Stats['status'] == "exists"): if ($bf3Stats['task'][result] == "found"): $tempData['players'][] = $newsEntry->userid_tbusers; endif; endif; endif; endforeach; $bf3Stats = getPlayersBF3Info($tempData); unset($bf3Stats['failed']); // to make sure that non finded players won´t get into it. $varPlayerPosition = 0; foreach ($bf3Stats['list'] as $userEntry): if (isset($userEntry)): $varKills = $userEntry['stats']['global']['kills']; $varDeaths = $userEntry['stats']['global']['deaths']; $varSkill = $userEntry['stats']['global']['elo']; $varlastUpdate = $userEntry['date_update']; $varRatio = round(($varKills / $varDeaths), 2); else: $varRatio = 0; $varSkill = 0; $varlastUpdate = time() - 86400; endif; $memberFound = $memberObj->getDataByID($tempData['players'][$varPlayerPosition]); if (count($memberFound) > 0): $tempAttributes = array( 'skill_tbusers' => $varSkill, 'ratio_tbusers' => $varRatio, 'lastupdate_tbusers' => date('Y-m-d H:i:s', $varlastUpdate) ); $memberFound->updateTo($tempAttributes); endif; $varPlayerPosition += 1; endforeach; //=========================== End of script ==================================================================== function setupClientKey($clientident = null, $name = null) { $data = array(); $data['ident'] = BF3APIIdent; $data['time'] = time(); $data['clientident'] = $clientident; $data['name'] = $name; return getAPIDataSigned('setupkey', 'global', $data); } function getClientKey($clientident) { $data = array(); $data['ident'] = BF3APIIdent; $data['time'] = time(); $data['clientident'] = $clientident; return getAPIDataSigned('getkey', 'global', $data); } function lookupPlayer($platform, $name) { echo BF3APIIdent; $data = array(); $data['ident'] = BF3APIIdent; $data['time'] = time(); $data['player'] = $name; return getAPIDataSigned('playerlookup', $platform, $data); } function updatePlayer($platform, $name) { $data = array(); $data['ident'] = BF3APIIdent; $data['time'] = time(); $data['player'] = $name; return getAPIDataSigned('playerupdate', $platform, $data); } function getAPIDataSigned($type, $platform, $data) { // Convert data to JSON $urlbase64 = array('+' => '-', '/' => '_', '=' => ''); $data = strtr(base64_encode(json_encode($data)), $urlbase64); $postdata = array(); $postdata['data'] = $data; $postdata['sig'] = strtr(base64_encode(hash_hmac('sha256', $data, BF3APIKey, true)), $urlbase64); // Run POST Request via CURL $c = curl_init('http://api.bf3stats.com/' . $platform . '/' . $type . '/'); curl_setopt($c, CURLOPT_HEADER, false); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_USERAGENT, 'BF3StatsAPI/0.1'); curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($c); $statuscode = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); if ($statuscode == 200) { // Decode JSON Data $data = json_decode($data, true); return $data; } else { echo "BF3 Stats API error status: " . $statuscode; return false; } } function getPlayersBF3Info($data) { // List of options $data['opt']['clear'] = true; $data['opt']['global'] = true; $data['time'] = time(); // Platform can be pc, 360, ps3 $platform = 'pc'; // Convert lists to JSON $postdata = array(); $postdata['players'] = json_encode($data['players']); $postdata['opt'] = json_encode($data['opt']); // Run POST Request via CURL $c = curl_init('http://api.bf3stats.com/' . $platform . '/playerlist/'); curl_setopt($c, CURLOPT_HEADER, false); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_USERAGENT, 'BF3StatsAPI/0.1'); curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($c); $statuscode = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); if ($statuscode == 200) { // Decode JSON Data $data = json_decode($data, true); // Print data for debugging return $data; // ... now you use $data to do whatever } else { return "ERROR"; } } ?>

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.0070.00716.80
7.1.200.0070.00715.41
7.1.70.0040.00417.06
7.1.60.0110.01519.40
7.1.50.0200.01334.83
7.1.00.0030.04722.36
7.0.200.1520.00614.46
7.0.140.0070.07022.00
7.0.90.0500.06720.00
7.0.80.0030.08719.98
7.0.70.0600.06019.93
7.0.60.0430.07019.92
7.0.50.0070.04320.40
7.0.40.0100.08020.18
7.0.30.0100.07020.04
7.0.20.0000.05320.10
7.0.10.0100.05720.14
7.0.00.0030.04720.17
5.6.280.0100.07021.07
5.6.240.0170.06720.58
5.6.230.0130.07020.48
5.6.220.0100.05720.58
5.6.210.0070.04720.75
5.6.200.0030.04321.18
5.6.190.0070.08321.10
5.6.180.0100.06321.08
5.6.170.0130.08321.11
5.6.160.0100.08021.13
5.6.150.0030.06020.99
5.6.140.0070.05021.06
5.6.130.0130.08721.16
5.6.120.0030.04321.14
5.6.110.0070.08321.09
5.6.100.0070.04721.04
5.6.90.0130.04321.05
5.6.80.0100.05720.61
5.6.70.0100.07320.55
5.6.60.0000.05020.53
5.6.50.0070.03320.46
5.6.40.0070.04020.43
5.6.30.0000.04720.43
5.6.20.0070.04020.37
5.6.10.0130.02720.51
5.6.00.0030.04020.57
5.5.380.0070.07320.36
5.5.370.0100.07020.51
5.5.360.0030.09320.44
5.5.350.0100.08320.42
5.5.340.0100.03720.96
5.5.330.0070.10020.82
5.5.320.0130.07720.95
5.5.310.0030.08720.91
5.5.300.0070.06020.79
5.5.290.0070.08320.83
5.5.280.0070.06720.70
5.5.270.0000.06320.78
5.5.260.0100.07320.78
5.5.250.0070.04020.73
5.5.240.0100.05720.21
5.5.230.0000.04320.36
5.5.220.0070.03720.35
5.5.210.0030.04020.24
5.5.200.0100.04320.24
5.5.190.0000.05720.21
5.5.180.0100.03720.27
5.5.160.0030.03320.30
5.5.150.0030.03320.04
5.5.140.0130.03020.32
5.5.130.0100.03320.31
5.5.120.0030.04020.20
5.5.110.0070.04320.29
5.5.100.0000.03720.13
5.5.90.0000.03320.13
5.5.80.0100.04320.15
5.5.70.0130.07020.11
5.5.60.0070.03720.09
5.5.50.0030.04020.21
5.5.40.0070.03320.11
5.5.30.0070.03720.15
5.5.20.0000.04020.20
5.5.10.0030.04020.07
5.5.00.0070.03720.05
5.4.450.0130.04719.36
5.4.440.0100.06319.38
5.4.430.0070.04319.35
5.4.420.0100.03719.53
5.4.410.0100.06319.24
5.4.400.0170.06019.05
5.4.390.0070.07719.13
5.4.380.0030.04019.11
5.4.370.0000.04019.25
5.4.360.0030.04719.23
5.4.350.0030.04019.23
5.4.340.0000.04318.88
5.4.320.0030.03018.85
5.4.310.0070.03019.16
5.4.300.0100.03319.09
5.4.290.0070.03019.16
5.4.280.0030.03318.85
5.4.270.0070.03019.23
5.4.260.0000.04319.13
5.4.250.0100.02319.02
5.4.240.0030.03019.12
5.4.230.0070.05719.17
5.4.220.0000.05719.20
5.4.210.0000.04719.12
5.4.200.0000.04319.18
5.4.190.0070.03019.15
5.4.180.0030.04018.95
5.4.170.0000.04319.04
5.4.160.0000.03319.12
5.4.150.0030.03318.93
5.4.140.0030.03716.39
5.4.130.0070.03716.41
5.4.120.0100.02316.50
5.4.110.0030.03716.44
5.4.100.0000.04016.57
5.4.90.0100.03016.48
5.4.80.0070.03716.41
5.4.70.0030.03016.39
5.4.60.0030.03016.42
5.4.50.0100.02316.44
5.4.40.0030.03016.46
5.4.30.0100.02716.36
5.4.20.0030.03016.51
5.4.10.0070.06716.43
5.4.00.0030.03015.92
5.3.290.0000.04714.73
5.3.280.0070.03014.54
5.3.270.0100.04014.62
5.3.260.0030.03014.80
5.3.250.0030.03714.62
5.3.240.0030.03314.77
5.3.230.0070.08014.68
5.3.220.0000.03314.64
5.3.210.0000.03714.52
5.3.200.0030.04314.61
5.3.190.0000.04014.66
5.3.180.0070.02714.65
5.3.170.0030.03314.64
5.3.160.0070.02714.65
5.3.150.0030.03014.55
5.3.140.0000.04014.66
5.3.130.0100.03714.67
5.3.120.0000.03714.67
5.3.110.0070.03014.53
5.3.100.0030.07014.10
5.3.90.0070.07314.11
5.3.80.0070.05714.11
5.3.70.0030.08014.13
5.3.60.0070.08314.13
5.3.50.0070.03714.11
5.3.40.0070.06013.94
5.3.30.0000.04013.96
5.3.20.0100.06013.79
5.3.10.0030.06313.62
5.3.00.0100.03313.69

preferences:
32.27 ms | 401 KiB | 5 Q