3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once 'http://vengeanceofwar.pusku.com/config.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.4.00.0110.00815.19
7.3.120.0110.00614.80
7.3.110.0180.00014.94
7.3.100.0030.01014.67
7.3.90.0070.00414.66
7.3.80.0030.00614.92
7.3.70.0080.00814.91
7.3.60.0030.00714.72
7.3.50.0040.00414.85
7.3.40.0070.00714.84
7.3.30.0100.00714.88
7.3.20.0030.00716.59
7.3.10.0120.00316.38
7.3.00.0040.01216.32
7.2.250.0130.00015.02
7.2.240.0120.00914.90
7.2.230.0030.01214.90
7.2.220.0040.01214.89
7.2.210.0060.00914.85
7.2.200.0060.00314.83
7.2.190.0040.01115.02
7.2.180.0100.00315.09
7.2.170.0110.00414.83
7.2.00.0040.01219.25
7.1.330.0030.01015.38
7.1.320.0100.00315.57
7.1.310.0110.00415.36
7.1.300.0030.00615.67
7.1.290.0090.00915.51
7.1.280.0000.01715.71
7.1.270.0030.00715.67
7.1.260.0000.01715.68
7.1.100.0090.00018.26
7.1.70.0000.00816.74
7.1.60.0060.01819.17
7.1.50.0180.00716.59
7.1.00.0070.03022.45
7.0.200.0000.00816.70
7.0.140.0000.04722.01
7.0.100.0170.05720.02
7.0.90.0000.08719.96
7.0.80.0100.04319.98
7.0.70.0070.05720.05
7.0.60.0030.08720.09
7.0.50.0170.07320.38
7.0.40.0070.08720.14
7.0.30.0030.08719.96
7.0.20.0100.08320.13
7.0.10.0030.06320.13
7.0.00.0030.04720.05
5.6.280.0070.07020.96
5.6.250.0030.05020.66
5.6.240.0130.07020.70
5.6.230.0130.08020.56
5.6.220.0130.06720.73
5.6.210.0070.05720.72
5.6.200.0200.07721.23
5.6.190.0070.08321.11
5.6.180.0070.05021.02
5.6.170.0070.07321.00
5.6.160.0070.09321.13
5.6.150.0100.08021.11
5.6.140.0030.04321.14
5.6.130.0070.08721.16
5.6.120.0030.08021.13
5.6.110.0100.04021.22
5.6.100.0000.05321.06
5.6.90.0000.05321.11
5.6.80.0030.07720.47
5.6.70.0170.06020.38
5.6.60.0130.06720.44
5.6.50.0100.07720.41
5.6.40.0130.07320.49
5.6.30.0130.07720.44
5.6.20.0070.08720.46
5.6.10.0070.06720.50
5.6.00.0030.07020.47
5.5.380.0170.07720.51
5.5.370.0030.05320.60
5.5.360.0030.08720.46
5.5.350.0030.08720.46
5.5.340.0030.08020.95
5.5.330.0030.08720.95
5.5.320.0100.06020.95
5.5.310.0170.07020.95
5.5.300.0070.06020.86
5.5.290.0100.04720.99
5.5.280.0170.07320.90
5.5.270.0130.06320.98
5.5.260.0070.08320.98
5.5.250.0030.08320.74
5.5.240.0100.07320.09
5.5.230.0100.08020.22
5.5.220.0100.08020.24
5.5.210.0100.07320.36
5.5.200.0100.07720.34
5.5.190.0170.07020.24
5.5.180.0070.05320.17
5.5.160.0100.07720.17
5.5.150.0100.04020.20
5.5.140.0100.07020.20
5.5.130.0030.09020.30
5.5.120.0130.07020.28
5.5.110.0200.06720.26
5.5.100.0100.08020.22
5.5.90.0070.05320.10
5.5.80.0170.07020.16
5.5.70.0100.07720.11
5.5.60.0070.04320.00
5.5.50.0070.07020.12
5.5.40.0030.07720.09
5.5.30.0130.06320.09
5.5.20.0130.04020.21
5.5.10.0130.07720.20
5.5.00.0030.04720.06
5.4.450.0000.08719.29
5.4.440.0070.09319.18
5.4.430.0200.07019.45
5.4.420.0030.05719.41
5.4.410.0070.03719.32
5.4.400.0100.07319.17
5.4.390.0030.04719.18
5.4.380.0030.07719.13
5.4.370.0070.07319.03
5.4.360.0100.07018.90
5.4.350.0030.04719.05
5.4.340.0130.04719.03
5.4.320.0070.05719.13
5.4.310.0100.07319.16
5.4.300.0030.07718.86
5.4.290.0200.03319.06
5.4.280.0170.07019.12
5.4.270.0030.06719.00
5.4.260.0070.08018.90
5.4.250.0030.07718.88
5.4.240.0100.07019.06
5.4.230.0100.07719.08
5.4.220.0130.07319.12
5.4.210.0130.07018.94
5.4.200.0070.07319.22
5.4.190.0130.06719.12
5.4.180.0100.07019.02
5.4.170.0000.06319.11
5.4.160.0030.04019.16
5.4.150.0030.04319.18
5.4.140.0030.07016.39
5.4.130.0100.03716.44
5.4.120.0130.03316.39
5.4.110.0170.07016.60
5.4.100.0030.07016.53
5.4.90.0100.07316.42
5.4.80.0070.04716.39
5.4.70.0100.04016.43
5.4.60.0100.06716.42
5.4.50.0100.04016.35
5.4.40.0030.07716.36
5.4.30.0100.07316.42
5.4.20.0070.07016.35
5.4.10.0000.08316.44
5.4.00.0070.04715.77
5.3.290.0000.07014.71
5.3.280.0130.06314.79
5.3.270.0070.08014.65
5.3.260.0130.03014.73
5.3.250.0030.04014.64
5.3.240.0070.06714.69
5.3.230.0030.06314.80
5.3.220.0070.03714.72
5.3.210.0000.09014.56
5.3.200.0070.07314.68
5.3.190.0130.06314.66
5.3.180.0000.05714.64
5.3.170.0000.08314.61
5.3.160.0030.07714.60
5.3.150.0170.06714.61
5.3.140.0070.04714.71
5.3.130.0130.05314.53
5.3.120.0130.07014.64
5.3.110.0130.03714.58
5.3.100.0100.07014.02
5.3.90.0100.07014.01
5.3.80.0070.07014.20
5.3.70.0100.06714.21
5.3.60.0100.07013.95
5.3.50.0100.07014.03
5.3.40.0070.07714.07
5.3.30.0030.04314.03
5.3.20.0030.04013.82
5.3.10.0030.07013.77
5.3.00.0000.05013.71

preferences:
30.51 ms | 400 KiB | 5 Q