3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * TME API - code snippet. * * More info at: https://developers.tme.eu */ if(!function_exists('hash_hmac')) function hash_hmac($algo, $data, $key, $raw_output = false) { $algo = strtolower($algo); $pack = 'H'.strlen($algo('test')); $size = 64; $opad = str_repeat(chr(0x5C), $size); $ipad = str_repeat(chr(0x36), $size); if (strlen($key) > $size) { $key = str_pad(pack($pack, $algo($key)), $size, chr(0x00)); } else { $key = str_pad($key, $size, chr(0x00)); } for ($i = 0; $i < strlen($key) - 1; $i++) { $opad[$i] = $opad[$i] ^ $key[$i]; $ipad[$i] = $ipad[$i] ^ $key[$i]; } $output = $algo($opad.pack($pack, $algo($ipad.$data))); return ($raw_output) ? pack($pack, $output) : $output; } ini_set('display_errors', 1); error_reporting(E_ALL); $token = 'b050bd709a43eecc443820c022b6774ca703ddb216b6f6765f';//'<put_your_token_here>'; $app_secret = '5656847466f0e5d08577';//<put_your_app_secret_here>'; $params = array( 'SymbolList' => array('1N4007'), 'Country' => 'PL', 'Currency' => 'PLN', 'Language' => 'PL', ); $response = api_call('Products/GetPrices', $params, $token, $app_secret, true); $result = json_decode($response, true); var_dump(PHP_VERSION); echo '<pre>'; print_r($result); echo '</pre>'; //--------------------------------------------------------- function api_call($action, $params, $token, $app_secret, $show_header=false) { $api_url = 'https://api.tme.eu/' . $action . '.json'; // calculate HMAC-SHA1 signature $params['Token'] = $token; ksort($params); // In PHP 5.4 http_build_query() offers enc_type parameter (PHP_QUERY_RFC3986) which replaces bellow snippet. $encoded_params = str_replace( array('+', '%7E'), array('%20', '~'), http_build_query($params) ); $signature_base = 'POST' . '&' . rawurlencode($api_url) . '&' . rawurlencode($encoded_params); $api_signature = base64_encode(hash_hmac('sha1', $signature_base, $app_secret, true)); $params['ApiSignature'] = $api_signature; $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($params) ) ); return file_get_contents($api_url, false, stream_context_create($opts)); }

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)
5.4.260.3930.03719.13
5.4.250.4100.04719.21
5.4.240.3970.03319.20
5.4.230.3870.03719.23
5.4.220.3870.03718.98
5.4.210.3870.04319.04
5.4.200.3800.03718.94
5.4.190.4300.03718.92
5.4.180.4200.04719.21
5.4.170.3430.04019.20
5.4.160.3500.02719.04
5.4.150.3730.03719.02
5.4.140.3730.03316.45
5.4.130.3430.03716.34
5.4.120.3630.03316.35
5.4.110.3570.03316.39
5.4.100.3570.03716.57
5.4.90.3900.02316.25
5.4.80.3970.03016.46
5.4.70.3570.04016.22
5.4.60.3870.03716.32
5.4.50.3730.04016.45
5.4.40.3770.04016.58
5.4.30.3870.03316.22
5.4.20.3970.03016.50
5.4.10.3900.03716.46
5.4.00.3870.03715.95
5.3.280.3870.03714.57
5.3.270.4200.04314.54
5.3.260.3600.04014.63
5.3.250.3370.03714.70
5.3.240.3400.03714.54
5.3.230.3370.03014.61
5.3.220.3330.03314.45
5.3.210.3170.04014.66
5.3.200.3670.03714.53
5.3.190.3970.03314.46
5.3.180.3870.03714.35
5.3.170.3670.03714.52
5.3.160.3970.02714.39
5.3.150.4030.03314.49
5.3.140.3670.04314.43
5.3.130.3730.04014.48
5.3.120.3770.04314.49
5.3.110.3900.04014.34
5.3.100.3830.02713.97
5.3.90.3930.03713.99
5.3.80.3830.04013.83
5.3.70.3800.04313.83
5.3.60.4170.03713.82
5.3.50.3930.03713.87
5.3.40.3500.04313.78
5.3.30.3870.03013.72
5.3.20.3830.03713.78
5.3.10.3830.03713.59
5.3.00.3970.03313.59

preferences:
147.31 ms | 1394 KiB | 7 Q