3v4l.org

run code in 300+ PHP versions simultaneously
<?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://'; $message = array( 'topic' => 'updateCusNumberRequest', 'email' => 'test', 'cus_id' => '123' ); $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"; } 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/ZeSVQ5 function php_compat_hash_hmac($algo, $data, $key, $raw_output = false) { $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 . hash($algo, $ipad . $data, true), $raw_output); } //http://bit.ly/ZeSVQ5 function php_compat_hash($algo, $data, $raw_output = false) { $algo = strtolower($algo); switch ($algo) { case 'md5': $hash = md5($data); break; case 'sha1': if (!function_exists('sha1')) { require dirname(__FILE__) . '/sha1.php'; } $hash = sha1($data); break; case 'sha256': //if (!function_exists('php_compat_sha256')) { // require dirname(__FILE__) . '/_sha256.php'; //} //$hash = php_compat_sha256($data); require_once dirname(__FILE__) . '/sha256.php'; $hash = SHA256::hash($data); break; default: user_error('hash(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING); return false; } if ($raw_output) { return pack('H*', $hash); } else { 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); } ?>

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.0190.00316.86
8.3.50.0100.00722.95
8.3.40.0030.01219.27
8.3.30.0110.00419.43
8.3.20.0080.00020.34
8.3.10.0000.00823.53
8.3.00.0050.00319.75
8.2.180.0060.00917.00
8.2.170.0070.00722.96
8.2.160.0100.01020.65
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00421.10
8.2.110.0050.00520.50
8.2.100.0090.00318.47
8.2.90.0000.01219.34
8.2.80.0060.00317.97
8.2.70.0060.00317.75
8.2.60.0000.00818.16
8.2.50.0090.00018.07
8.2.40.0000.01318.47
8.2.30.0040.00418.15
8.2.20.0000.00817.91
8.2.10.0000.00818.27
8.2.00.0040.00417.83
8.1.280.0120.00425.92
8.1.270.0000.00823.84
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00423.98
8.1.230.0050.00518.97
8.1.220.0080.00017.89
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0000.00817.38
8.1.180.0090.00019.14
8.1.170.0060.00318.84
8.1.160.0040.00422.03
8.1.150.0030.00518.91
8.1.140.0080.00017.53
8.1.130.0080.00017.85
8.1.120.0000.00717.61
8.1.110.0000.00817.52
8.1.100.0040.00417.63
8.1.90.0030.00517.64
8.1.80.0000.00717.65
8.1.70.0070.00017.63
8.1.60.0030.00617.64
8.1.50.0050.00317.75
8.1.40.0000.00817.70
8.1.30.0000.00817.75
8.1.20.0030.00617.85
8.1.10.0040.00417.68
8.1.00.0040.00417.67
8.0.300.0080.00018.77
8.0.290.0040.00417.13
8.0.280.0050.00218.54
8.0.270.0050.00317.45
8.0.260.0060.00017.54
8.0.250.0000.00717.26
8.0.240.0030.00317.25
8.0.230.0040.00417.09
8.0.220.0050.00317.24
8.0.210.0000.00817.19
8.0.200.0030.00317.06
8.0.190.0090.00017.05
8.0.180.0040.00417.17
8.0.170.0030.00617.20
8.0.160.0000.00817.10
8.0.150.0050.00317.11
8.0.140.0000.00917.02
8.0.130.0030.00313.59
8.0.120.0080.00315.29
8.0.110.0070.00415.38
8.0.100.0060.00515.23
8.0.90.0080.00315.30
8.0.80.0080.01015.37
8.0.70.0070.00415.35
8.0.60.0040.00715.29
8.0.50.0080.00315.27
8.0.30.0100.00915.91
8.0.20.0100.00816.11
8.0.10.0070.00315.36
8.0.00.0040.00915.85
7.4.330.0060.00015.07
7.4.320.0030.00316.72
7.4.300.0030.00316.63
7.4.290.0030.00316.69
7.4.280.0040.00416.74
7.4.270.0050.00316.56
7.4.260.0050.00316.62
7.4.250.0050.00314.98
7.4.240.0070.00315.55
7.4.230.0090.00215.06
7.4.220.0110.00515.00
7.4.210.0030.01215.01
7.4.200.0080.00015.04
7.4.190.0030.00313.47
7.4.180.0000.00613.46
7.4.160.0050.00715.16
7.4.150.0040.00715.41
7.4.140.0080.00516.35
7.4.130.0060.00915.65
7.4.120.0080.00715.62
7.4.110.0050.00615.00
7.4.100.0050.00715.09
7.4.90.0030.00914.96
7.4.80.0090.00416.35
7.4.70.0040.00915.01
7.4.60.0100.00315.06
7.4.50.0010.00514.95
7.4.40.0060.00815.05
7.4.30.0070.00615.07
7.4.20.0000.00813.34
7.4.10.0060.00313.23
7.4.00.0060.00914.66
7.3.330.0040.00413.44
7.3.320.0050.00013.58
7.3.310.0030.00515.09
7.3.300.0030.00415.04
7.3.290.0070.00515.09
7.3.280.0090.00415.86
7.3.270.0060.00715.54
7.3.260.0070.00715.05
7.3.250.0060.00915.62
7.3.240.0110.00315.18
7.3.230.0020.01215.11
7.3.220.0050.00313.38
7.3.210.0050.00815.07
7.3.200.0060.00916.49
7.3.190.0060.00915.13
7.3.180.0090.00315.04
7.3.170.0080.00815.04
7.3.160.0090.00415.12
7.3.150.0000.00813.55
7.3.140.0050.00313.62
7.3.130.0070.00013.39
7.3.120.0030.00614.19
7.3.110.0080.00414.25
7.3.100.0030.00814.27
7.3.90.0030.00514.30
7.3.80.0060.00214.38
7.3.70.0020.00714.21
7.3.60.0050.00614.17
7.3.50.0020.00814.32
7.3.40.0020.00814.28
7.3.30.0030.00914.25
7.3.20.0090.00016.10
7.3.10.0070.00416.24
7.3.00.0040.00616.42
7.2.340.0060.00613.68
7.2.330.0110.00515.24
7.2.320.0130.00515.32
7.2.310.0070.01115.05
7.2.300.0080.00715.24
7.2.290.0080.00715.24
7.2.280.0090.00313.65
7.2.270.0080.00413.43
7.2.260.0090.00413.65
7.2.250.0090.00714.45
7.2.240.0090.00814.45
7.2.230.0030.01114.39
7.2.220.0050.00814.29
7.2.210.0050.00914.15
7.2.200.0090.00414.47
7.2.190.0070.00414.39
7.2.180.0100.00214.49
7.2.170.0060.00714.54
7.2.160.0120.00013.58
7.2.150.0130.00015.43
7.2.140.0130.00015.23
7.2.130.0080.00716.50
7.2.120.0070.00516.48
7.2.110.0050.00816.47
7.2.100.0110.00216.50
7.2.90.0100.00416.58
7.2.80.0090.00616.51
7.2.70.0030.01016.46
7.2.60.0050.00816.61
7.2.50.0060.00816.49
7.2.40.0030.00916.41
7.2.30.0100.00416.51
7.2.20.0060.00816.34
7.2.10.0080.00616.55
7.2.00.0080.00516.54
7.1.330.0070.00515.04
7.1.320.0070.00515.21
7.1.310.0100.00415.12
7.1.300.0090.00415.09
7.1.290.0080.00515.14
7.1.280.0060.00715.05
7.1.270.0050.00915.21
7.1.260.0070.00315.20
7.1.250.0060.00715.45
7.1.240.0070.00514.29
7.1.230.0090.00314.48
7.1.220.0000.01214.20
7.1.210.0040.00814.44
7.1.200.0050.00715.10
7.1.190.0090.00314.53
7.1.180.0100.00214.48
7.1.170.0070.00514.43
7.1.160.0070.00514.36
7.1.150.0090.00314.41
7.1.140.0120.00014.40
7.1.130.0090.00414.36
7.1.120.0040.00814.40
7.1.110.0120.00014.36
7.1.100.0130.00014.38
7.1.90.0130.00014.41
7.1.80.0070.00514.34
7.1.70.0090.00315.85
7.1.60.0080.01116.98
7.1.50.0080.00415.74
7.1.40.0040.00814.46
7.1.30.0080.00414.21
7.1.20.0060.00614.42
7.1.10.0080.00414.23
7.1.00.0080.03818.39
7.0.330.0080.00414.20
7.0.320.0110.00014.17
7.0.310.0060.00614.16
7.0.300.0080.00414.09
7.0.290.0000.01214.32
7.0.280.0120.00014.24
7.0.270.0080.00414.24
7.0.260.0060.00614.27
7.0.250.0070.00714.46
7.0.240.0090.00314.23
7.0.230.0100.00214.48
7.0.220.0090.00314.37
7.0.210.0040.00814.17
7.0.200.0030.00715.48
7.0.190.0100.00214.38
7.0.180.0120.00014.28
7.0.170.0090.00314.31
7.0.160.0060.00614.18
7.0.150.0090.00314.14
7.0.140.0050.03818.07
7.0.130.0120.00014.39
7.0.120.0130.00014.39
7.0.110.0080.00414.28
7.0.100.0050.02517.22
7.0.90.0170.04417.09
7.0.80.0090.03817.08
7.0.70.0120.03817.15
7.0.60.0130.04017.13
7.0.50.0050.04617.34
7.0.40.0070.02517.21
7.0.30.0100.03717.22
7.0.20.0070.04417.10
7.0.10.0060.02617.14
7.0.00.0030.02917.16
5.6.400.0070.00413.11
5.6.390.0120.00013.11
5.6.380.0090.00212.99
5.6.370.0080.00412.87
5.6.360.0040.00813.11
5.6.350.0050.00513.04
5.6.340.0060.00612.97
5.6.330.0090.00212.98
5.6.320.0090.00313.06
5.6.310.0040.00812.99
5.6.300.0090.00213.00
5.6.290.0080.00413.06
5.6.280.0090.03517.03
5.6.270.0080.00412.98
5.6.260.0070.00412.80
5.6.250.0080.02516.75
5.6.240.0110.03016.79
5.6.230.0080.04316.93
5.6.220.0110.04016.69
5.6.210.0000.03016.81
5.6.200.0070.03517.11
5.6.190.0110.03816.99
5.6.180.0080.03617.05
5.6.170.0090.02717.12
5.6.160.0060.03317.20
5.6.150.0040.02917.15
5.6.140.0140.01717.02
5.6.130.0110.03816.95
5.6.120.0060.04817.09
5.6.110.0090.04116.99
5.6.100.0070.04317.00
5.6.90.0110.03616.97
5.6.80.0120.03716.65
5.6.70.0070.02816.81
5.6.60.0150.01716.69
5.6.50.0080.02616.65
5.6.40.0060.04516.72
5.6.30.0090.03516.83
5.6.20.0090.04116.72
5.6.10.0070.03716.80
5.6.00.0070.03716.66
5.5.380.0040.02916.84
5.5.370.0030.04316.86
5.5.360.0120.04216.62
5.5.350.0100.03616.60
5.5.340.0100.02316.77
5.5.330.0090.02316.84
5.5.320.0070.03316.87
5.5.310.0070.03216.94
5.5.300.0070.04016.88
5.5.290.0100.02616.87
5.5.280.0070.04416.88
5.5.270.0130.04016.96
5.5.260.0060.04516.80
5.5.250.0060.03916.87
5.5.240.0060.04516.64
5.5.230.0110.03816.65
5.5.220.0110.01816.55
5.5.210.0110.03816.62
5.5.200.0090.02216.62
5.5.190.0070.04516.47
5.5.180.0030.03616.69
5.5.170.0070.00512.69
5.5.160.0110.03816.52
5.5.150.0080.03616.43
5.5.140.0080.02316.56
5.5.130.0080.02116.61
5.5.120.0060.02216.46
5.5.110.0050.02316.53
5.5.100.0080.02016.59
5.5.90.0040.02216.52
5.5.80.0080.02716.59
5.5.70.0090.01516.54
5.5.60.0100.02016.54
5.5.50.0090.01916.52
5.5.40.0050.04216.58
5.5.30.0100.01516.48
5.5.20.0080.02016.53
5.5.10.0090.01816.63
5.5.00.0090.01816.58
5.4.450.0100.04316.25
5.4.440.0080.04216.12
5.4.430.0110.03815.95
5.4.420.0070.02816.13
5.4.410.0090.04016.07
5.4.400.0090.03815.98
5.4.390.0040.02315.85
5.4.380.0090.02215.90
5.4.370.0090.03515.94
5.4.360.0090.03715.96
5.4.350.0080.03616.03
5.4.340.0060.04215.93
5.4.330.0110.00012.69
5.4.320.0060.03615.89
5.4.310.0070.02916.04
5.4.300.0020.02615.97
5.4.290.0060.02116.07
5.4.280.0090.02115.94
5.4.270.0040.02415.97
5.4.260.0070.02215.77
5.4.250.0050.02015.82
5.4.240.0040.02316.01
5.4.230.0080.01815.83
5.4.220.0060.02215.89
5.4.210.0050.01815.72
5.4.200.0040.02215.86
5.4.190.0080.01815.70
5.4.180.0050.02115.85
5.4.170.0080.01716.00
5.4.160.0060.02215.88
5.4.150.0030.03115.91
5.4.140.0040.02114.63
5.4.130.0080.01614.72
5.4.120.0070.01814.62
5.4.110.0080.01814.65
5.4.100.0080.03514.68
5.4.90.0050.02314.71
5.4.80.0040.02114.66
5.4.70.0050.02114.70
5.4.60.0060.02014.80
5.4.50.0070.01814.64
5.4.40.0060.02014.73
5.4.30.0070.01714.77
5.4.20.0080.01514.66
5.4.10.0070.01914.80
5.4.00.0100.01514.22

preferences:
42.25 ms | 401 KiB | 5 Q