3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Makes an API request to elucidat * @param $headers * @param $fields * @param $url * @param $consumer_secret * @return mixed */ function call_elucidat($headers, $fields, $method, $url, $consumer_secret){ //Build a signature $headers['oauth_signature'] = build_signature($consumer_secret, array_merge($headers, $fields), $method, $url); //Build OAuth headers $auth_headers = 'Authorization:'; $auth_headers .= build_base_string($headers, ','); //Build the request string $fields_string = build_base_string($fields, '&'); //Set the headers $header = array($auth_headers, 'Expect:'); // Create curl options if(strcasecmp($method, "GET") == 0){ $url .= '?'.$fields_string; $options = array( CURLOPT_HTTPHEADER => $header, CURLOPT_HEADER => false, CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false); } else { $options = array( CURLOPT_HTTPHEADER => $header, CURLOPT_HEADER => false, CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => count($fields), CURLOPT_POSTFIELDS => $fields_string); } //Init the request and set its params $request = curl_init(); curl_setopt_array($request, $options); //Make the request $response = curl_exec($request); $status = curl_getinfo($request, CURLINFO_HTTP_CODE); curl_close($request); return array( 'status' => $status, 'response' => json_decode($response, true) ); } /** * Each request to the elucidat API must be accompanied by a unique key known as a nonce. * This key adds an additional level of security to the API. * A new key must be requested for each API call. * @param $api_url * @param $consumer_key * @param $consumer_secret * @return bool */ function get_nonce($api_url, $consumer_key, $consumer_secret){ // Start with some standard headers, unsetting the oauth_nonce. without the nonce header the API will automatically issue us one. $auth_headers = auth_headers($consumer_key); unset($auth_headers['oauth_nonce']); //Make a request to elucidat for a nonce...any url is fine providing it doesnt already have a nonce $json = call_elucidat($auth_headers, array(), 'GET', $api_url, $consumer_secret); if(isset($json['response']['nonce'])){ return $json['response']['nonce']; } return false; } /** * Computes and returns a signature for the request. * @param $secret * @param $fields * @param $request_type * @param $url * @return string */ function build_signature($secret, $fields, $request_type, $url){ ksort($fields); //Build base string to be used as a signature $base_info = $request_type.'&'.$url.'&'.build_base_string($fields, '&'); //return complete base string //Create the signature from the secret and base string $composite_key = rawurlencode($secret); return base64_encode(hash_hmac('sha1', $base_info, $composite_key, true)); } /** * Builds a segment from an array of fields. Its used to create string representations of headers and URIs * @param $fields * @param $delim * @return string */ function build_base_string($fields, $delim){ $r = array(); foreach($fields as $key=>$value){ $r[] = rawurlencode($key) . "=" . rawurlencode($value); } return implode($delim, $r); //return complete base string } /** * Returns typical headers needed for a request * @param $consumer_key * @param $nonce */ function auth_headers($consumer_key, $nonce = ''){ return array('oauth_consumer_key' => $consumer_key, 'oauth_nonce' => $nonce, 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => time(), 'oauth_version' => '1.0'); } $nonce = get_nonce('https://api.elucidat.com/v2/projects', '1558A022-336C-6922-4B1F-AD3505839D5A', 'A393E5ED-C79F-4EB7-7DAE-9CB6C090B9E8'); $headers = auth_headers('1558A022-336C-6922-4B1F-AD3505839D5A', $nonce); $fields = array('simulation_mode'=>'simulation'); $result = call_elucidat($headers, $fields, 'GET', 'https://api.elucidat.com/v2/projects', 'A393E5ED-C79F-4EB7-7DAE-9CB6C090B9E8'); echo ("HTTP status code: " . $result['status'] . "\n"); print_r($result['response']);

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.0080.00616.84
7.2.00.0160.00319.54
7.1.200.0090.00615.85
7.1.100.0070.00718.06
7.1.70.0000.00716.82
7.1.60.0120.00919.27
7.1.50.0000.01517.13
7.1.00.0100.07022.43
7.0.200.0080.00316.99
7.0.80.0400.06020.08
7.0.70.0330.08719.92
7.0.60.0470.05320.07
7.0.50.0370.06320.32
7.0.40.0030.04320.13
7.0.30.0030.03720.14
7.0.20.0100.04320.07
7.0.10.0030.04720.03
7.0.00.0100.08319.95
5.6.280.0030.04321.13
5.6.230.0070.06320.77
5.6.220.0070.08320.61
5.6.210.0100.07720.78
5.6.200.0130.06721.07
5.6.190.0070.05021.19
5.6.180.0100.06720.99
5.6.170.0000.08321.13
5.6.160.0130.05021.05
5.6.150.0070.06021.13
5.6.140.0070.03721.03
5.6.130.0030.06721.10
5.6.120.0100.04721.04
5.6.110.0070.04020.95
5.6.100.0000.04321.04
5.6.90.0000.08321.06
5.6.80.0070.03720.37
5.6.70.0130.03720.42
5.6.60.0070.03720.47
5.6.50.0030.04020.58
5.6.40.0030.04020.46
5.6.30.0070.05720.47
5.6.20.0000.04320.33
5.6.10.0070.03320.51
5.6.00.0030.04720.38
5.5.370.0130.07720.39
5.5.360.0130.07320.55
5.5.350.0070.07320.48
5.5.340.0100.04720.79
5.5.330.0030.04720.90
5.5.320.0030.04320.91
5.5.310.0070.05320.76
5.5.300.0070.07320.89
5.5.290.0030.04320.91
5.5.280.0100.03720.94
5.5.270.0000.04320.84
5.5.260.0030.04020.77
5.5.250.0030.03720.57
5.5.240.0030.04020.17
5.5.230.0030.04020.05
5.5.220.0070.03720.32
5.5.210.0000.04320.26
5.5.200.0000.04020.27
5.5.190.0030.04720.11
5.5.180.0030.04020.26
5.5.160.0030.04020.29
5.5.150.0030.04020.09
5.5.140.0030.07320.28
5.5.130.0030.04020.11
5.5.120.0070.06020.28
5.5.110.0000.04320.10
5.5.100.0170.06720.13
5.5.90.0030.07720.13
5.5.80.0030.07320.09
5.5.70.0100.04320.09
5.5.60.0130.07720.18
5.5.50.0070.07320.09
5.5.40.0030.04320.14
5.5.30.0130.05020.17
5.5.20.0170.07020.18
5.5.10.0030.08020.07
5.5.00.0000.05720.05
5.4.450.0070.03719.36
5.4.440.0030.04019.48
5.4.430.0070.03719.20
5.4.420.0100.06019.47
5.4.410.0030.03719.22
5.4.400.0030.03319.10
5.4.390.0030.04019.18
5.4.380.0030.03319.04
5.4.370.0030.03718.95
5.4.360.0030.04319.14
5.4.350.0030.03318.95
5.4.340.0030.03719.12
5.4.320.0070.03718.86
5.4.310.0030.03718.95
5.4.300.0030.03719.04
5.4.290.0030.03719.02
5.4.280.0000.04019.16
5.4.270.0030.03719.02
5.4.260.0030.07319.04
5.4.250.0070.07318.87
5.4.240.0070.06719.04
5.4.230.0130.06018.94
5.4.220.0030.07319.11
5.4.210.0170.04719.02
5.4.200.0070.07319.13
5.4.190.0100.06319.17
5.4.180.0070.07719.13
5.4.170.0000.09018.89
5.4.160.0070.07719.10
5.4.150.0070.04018.86
5.4.140.0130.03016.39
5.4.130.0000.08016.46
5.4.120.0030.06316.24
5.4.110.0130.06716.44
5.4.100.0170.06316.39
5.4.90.0100.07016.52
5.4.80.0070.06716.55
5.4.70.0100.07016.54
5.4.60.0130.07316.43
5.4.50.0170.06316.37
5.4.40.0030.07716.38
5.4.30.0030.05016.31
5.4.20.0070.07716.41
5.4.10.0000.07716.45
5.4.00.0130.06315.86

preferences:
33.63 ms | 400 KiB | 5 Q