3v4l.org

run code in 300+ PHP versions simultaneously
<?php //require_once (dirname(__FILE__) . "/sha256.php"); $AWS_ACCESS_KEY = 'AKIAIDMODWRW3CRDO2BA'; $AWS_PRIVATE_KEY = 'kMuJRvcejqzMvmoZWsURIDKkteVTXa3ReDXQ6RqE'; $AWS_REGION = 'us-west-2'; $TOPIC_ARN_UPDATECUS = 'arn:aws:sns:us-west-2:791920038536:updateCusNumberRequest'; $endpoints = array( 'US-EAST-1' => 'sns.us-east-1.amazonaws.com', 'US-WEST-1' => 'sns.us-west-1.amazonaws.com', 'US-WEST-2' => 'sns.us-west-2.amazonaws.com', 'EU-WEST-1' => 'sns.eu-west-1.amazonaws.com', 'AP-SE-1' => 'sns.ap-southeast-1.amazonaws.com', 'AP-NE-1' => 'sns.ap-northeast-1.amazonaws.com', 'SA-EAST-1' => 'sns.sa-east-1.amazonaws.com' ); $endpoint = $endpoints[strtoupper($AWS_REGION)]; $protocol = 'https://'; $email = ''; $cus_id = ''; if ($argc >= 2) { $email = $argv[1]; $cus_id = $argv[2]; } $message = array( 'topic' => 'updateCusNumberRequest', 'email' => $email, 'cus_id' => $cus_id ); $params = array( 'TopicArn' => $TOPIC_ARN_UPDATECUS, 'Message' => php_compat_json_encode($message) ); $params['Action'] = 'Publish'; $params['AWSAccessKeyId'] = $AWS_ACCESS_KEY; $params['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $params['SignatureVersion'] = 2; $params['SignatureMethod'] = 'HmacSHA256'; uksort($params, 'strnatcmp'); $queryString = ''; foreach ($params as $key => $val) { $queryString .= "&{$key}=".rawurlencode($val); } $queryString = substr($queryString, 1); $requestString = "GET\n" . $endpoint."\n" . "/\n" . $queryString; $params['Signature'] = base64_encode( php_compat_hash_hmac('sha256', $requestString, $AWS_PRIVATE_KEY, true) ); $request = $protocol . $endpoint . '/?' . php_compat_http_build_query($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); $curlErrorNo = curl_errno($ch); $curlError = curl_error($ch); $info = curl_getinfo($ch); curl_close($ch); if ((floor($info['http_code'] / 100) == 2) === false) { if (strpos($output, '<Error>') !== FALSE) { echo "Amazon returned an XML error " . $output; } else{ if(!empty($curlErrorNo)) { echo "There was a problem executing curl" . $curlError . " - " . $curlErrorNo; } else{ echo "There was a problem executing this request " . $info['http_code']; } } } else { echo "All good!"; } /* php4 compatible functions */ //http://bit.ly/1qd0Usl function php_compat_hash_hmac($algo, $data, $key, $raw_output = false) { // Block size (byte) for MD5, SHA-1 and SHA-256. $blocksize = 64; $ipad = str_repeat("\x36", $blocksize); $opad = str_repeat("\x5c", $blocksize); if (strlen($key) > $blocksize) { $key = php_compat_hash($algo, $key, true); } else { $key = str_pad($key, $blocksize, "\x00"); } $ipad ^= $key; $opad ^= $key; return php_compat_hash($algo, $opad . php_compat_hash($algo, $ipad . $data, true), $raw_output); } //http://bit.ly/1nIYD2h function php_compat_hash($algo, $data, $raw_output = false) { $hash = hash('sha256', $data); if ($raw_output) { return pack('H*', $hash); } else { echo "returnhash"; return $hash; } } //http://bit.ly/1uH6OR0 function php_compat_json_encode($a=false) { if (is_null($a)) return 'null'; if ($a === false) return 'false'; if ($a === true) return 'true'; if (is_scalar($a)) { if (is_float($a)) { // Always use "." for floats. return floatval(str_replace(",", ".", strval($a))); } if (is_string($a)) { $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')); return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"'; } else return $a; } $isList = true; for ($i = 0, reset($a); $i < count($a); $i++, next($a)) { if (key($a) !== $i) { $isList = false; break; } } $result = array(); if ($isList) { foreach ($a as $v) $result[] = php_compat_json_encode($v); return '[' . join(',', $result) . ']'; } else { foreach ($a as $k => $v) $result[] = php_compat_json_encode($k).':'.php_compat_json_encode($v); return '{' . join(',', $result) . '}'; } } //http://bit.ly/1q8GwII function php_compat_http_build_query($data, $prefix = null, $sep = '', $key = '') { $ret = array(); foreach ((array )$data as $k => $v) { $k = urlencode($k); if (is_int($k) && $prefix != null) { $k = $prefix . $k; } if (!empty($key)) { $k = $key . "[" . $k . "]"; } if (is_array($v) || is_object($v)) { array_push($ret, http_build_query($v, "", $sep, $k)); } else { array_push($ret, $k . "=" . urlencode($v)); } } if (empty($sep)) { $sep = ini_get("arg_separator.output"); } return implode($sep, $ret); } if (!function_exists('hash')) { function hash($algo, $data) { if (empty($algo) || !is_string($algo) || !is_string($data)) { return false; } if (function_exists($algo)) { return $algo($data); } } } ?>

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)
8.3.60.0150.00617.00
8.3.50.0190.00822.99
8.3.40.0120.00318.93
8.3.30.0090.00619.22
8.3.20.0080.00020.04
8.3.10.0040.00423.39
8.3.00.0070.00319.50
8.2.180.0090.00918.38
8.2.170.0030.01322.96
8.2.160.0130.00020.47
8.2.150.0110.00024.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0000.00721.00
8.2.110.0100.00022.11
8.2.100.0030.00918.34
8.2.90.0070.00419.38
8.2.80.0030.00517.97
8.2.70.0050.00317.75
8.2.60.0000.00818.05
8.2.50.0060.00318.07
8.2.40.0100.00019.94
8.2.30.0050.00218.24
8.2.20.0030.00617.94
8.2.10.0000.00718.19
8.2.00.0030.00517.79
8.1.280.0080.00825.92
8.1.270.0000.00923.82
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0030.00623.83
8.1.230.0120.00019.10
8.1.220.0000.00817.91
8.1.210.0050.00318.77
8.1.200.0170.00017.34
8.1.190.0030.00617.38
8.1.180.0080.00018.10
8.1.170.0040.00418.78
8.1.160.0050.00322.16
8.1.150.0030.00618.91
8.1.140.0050.00217.67
8.1.130.0000.00717.81
8.1.120.0040.00417.64
8.1.110.0000.00817.65
8.1.100.0070.00317.68
8.1.90.0000.00717.69
8.1.80.0070.00017.57
8.1.70.0050.00317.63
8.1.60.0030.00617.61
8.1.50.0040.00417.53
8.1.40.0000.00817.60
8.1.30.0030.00517.57
8.1.20.0000.00817.73
8.1.10.0040.00417.55
8.1.00.0090.00417.62
8.0.300.0000.00818.77
8.0.290.0050.00316.88
8.0.280.0070.00018.50
8.0.270.0030.00617.30
8.0.260.0000.00717.29
8.0.250.0030.00317.16
8.0.240.0020.00517.06
8.0.230.0000.00817.13
8.0.220.0070.00017.13
8.0.210.0040.00417.17
8.0.200.0030.00317.04
8.0.190.0060.00317.13
8.0.180.0070.00417.11
8.0.170.0040.00417.09
8.0.160.0070.00016.89
8.0.150.0030.00516.90
8.0.140.0040.00416.86
8.0.130.0000.00713.53
8.0.120.0040.00417.06
8.0.110.0080.00017.07
8.0.100.0000.00716.85
8.0.90.0040.00417.04
8.0.80.0100.00716.97
8.0.70.0040.00417.11
8.0.60.0030.00516.91
8.0.50.0000.00816.96
8.0.30.0120.00817.37
8.0.20.0110.01117.40
8.0.10.0000.00817.10
8.0.00.0070.01016.89
7.4.330.0000.00615.09
7.4.320.0050.00316.66
7.4.300.0060.00016.68
7.4.290.0000.00716.62
7.4.280.0000.00716.50
7.4.270.0030.00316.75
7.4.260.0040.00416.54
7.4.250.0050.00316.64
7.4.240.0000.00816.58
7.4.230.0000.00716.78
7.4.220.0150.00316.71
7.4.210.0030.01816.65
7.4.200.0030.00316.59
7.4.160.0130.01016.86
7.4.150.0080.01317.40
7.4.140.0130.00817.86
7.4.130.0060.01116.69
7.4.120.0110.00816.73
7.4.110.0110.00716.66
7.4.100.0130.00516.57
7.4.90.0170.00016.67
7.4.80.0070.01019.39
7.4.70.0070.01016.61
7.4.60.0030.01316.60
7.4.50.0030.00616.75
7.4.40.0110.01116.39
7.4.30.0130.00616.63
7.4.00.0070.01015.27
7.3.330.0070.00013.36
7.3.320.0000.00513.38
7.3.310.0000.00816.49
7.3.300.0000.00816.41
7.3.290.0160.00316.64
7.3.280.0060.01316.54
7.3.270.0150.00317.40
7.3.260.0100.01416.82
7.3.250.0110.00716.60
7.3.240.0140.00516.50
7.3.230.0100.01416.70
7.3.210.0120.00316.59
7.3.200.0040.01216.65
7.3.190.0040.01516.73
7.3.180.0040.01416.52
7.3.170.0130.00316.53
7.3.160.0060.01216.80
7.2.330.0160.00316.91
7.2.320.0090.01216.79
7.2.310.0070.01116.59
7.2.300.0190.00016.95
7.2.290.0100.00716.88
7.2.60.0160.00916.61
7.1.200.0060.00615.96
7.1.100.0110.00417.91
7.1.70.0060.00317.29
7.1.60.0070.01419.40
7.1.50.0230.01035.03
7.1.00.0030.07722.36
7.0.200.2720.00316.83
7.0.140.0000.08022.09
7.0.110.0470.05720.13
7.0.100.0100.07020.03
7.0.90.0170.03020.04
7.0.80.0130.03319.98
7.0.70.0070.04020.12
7.0.60.0100.04320.02
7.0.50.0030.05020.17
7.0.40.0100.03319.79
7.0.30.0170.04019.74
7.0.20.0100.03719.78
7.0.10.0030.05019.73
7.0.00.0030.03719.71
5.6.280.0000.07720.91
5.6.260.0130.07720.71
5.6.250.0070.07320.71
5.6.240.0100.03720.60
5.6.230.0070.04020.60
5.6.220.0030.04020.69
5.6.210.0100.04320.73
5.6.200.0030.04020.67
5.6.190.0100.03720.76
5.6.180.0030.04320.74
5.6.170.0070.03320.66
5.6.160.0070.03320.67
5.6.150.0100.03020.60
5.6.140.0100.02720.63
5.6.130.0070.06320.70
5.6.120.0130.07020.67
5.6.110.0070.08020.68
5.6.100.0100.04320.59
5.6.90.0130.06020.69
5.6.80.0100.08020.10
5.6.70.0000.06020.06
5.6.60.0070.07720.05
5.6.50.0070.07320.13
5.6.40.0070.07019.93
5.6.30.0030.06320.04
5.6.20.0070.07719.96
5.6.10.0000.06320.05
5.6.00.0130.07019.99
5.5.380.0100.03717.56
5.5.370.0030.04017.59
5.5.360.0030.04017.71
5.5.350.0100.04017.63
5.5.340.0000.04318.00
5.5.330.0030.04018.08
5.5.320.0000.04018.14
5.5.310.0030.03718.26
5.5.300.0130.03318.16
5.5.290.0000.05018.14
5.5.280.0100.07717.95
5.5.270.0070.03718.13
5.5.260.0070.07018.28
5.5.250.0070.05717.94
5.5.240.0070.06317.64
5.5.230.0000.05717.37
5.5.220.0070.07717.45
5.5.210.0000.05717.43
5.5.200.0030.06017.38
5.5.190.0000.08017.51
5.5.180.0070.06317.33
5.5.160.0070.03317.50
5.5.150.0030.05317.51
5.5.140.0000.04017.29
5.5.130.0030.07017.47
5.5.120.0070.06717.69
5.5.110.0100.07317.63
5.5.100.0130.07017.41
5.5.90.0000.04017.51
5.5.80.0030.04017.51
5.5.70.0000.07017.21
5.5.60.0070.04717.26
5.5.50.0070.03317.32
5.5.40.0170.05317.49
5.5.30.0030.03317.25
5.5.20.0170.07017.38
5.5.10.0000.06017.43
5.5.00.0070.04717.21
5.4.450.0100.02719.65
5.4.440.0070.05019.31
5.4.430.0030.06019.63
5.4.420.0130.03019.50
5.4.410.0100.06719.20
5.4.400.0100.07719.34
5.4.390.0030.05318.99
5.4.380.0100.05719.13
5.4.370.0100.04718.99
5.4.360.0130.05019.13
5.4.350.0030.07018.95
5.4.340.0030.06019.02
5.4.320.0070.03719.16
5.4.310.0030.06018.95
5.4.300.0030.06719.01
5.4.290.0030.06319.34
5.4.280.0030.07319.24
5.4.270.0070.06718.98
5.4.260.0030.08018.94
5.4.250.0070.06018.99
5.4.240.0100.06719.16
5.4.230.0070.04018.98
5.4.220.0000.05318.99
5.4.210.0030.03719.00
5.4.200.0030.03319.22
5.4.190.0030.07719.01
5.4.180.0030.03719.13
5.4.170.0130.03019.15
5.4.160.0030.04018.98
5.4.150.0200.06719.32
5.4.140.0070.03716.39
5.4.130.0070.04316.68
5.4.120.0070.04716.44
5.4.110.0100.02316.55
5.4.100.0000.05016.64
5.4.90.0070.05316.52
5.4.80.0070.06716.51
5.4.70.0030.04316.40
5.4.60.0030.08016.62
5.4.50.0070.05016.62
5.4.40.0030.07716.57
5.4.30.0170.05016.59
5.4.20.0070.07316.43
5.4.10.0070.04716.60
5.4.00.0070.07015.94

preferences:
47.82 ms | 401 KiB | 5 Q