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' => $_POST["email"], 'cus_id' => $_POST["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"; } 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) { // 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 = hash($algo, $key, true); } else { $key = str_pad($key, $blocksize, "\x00"); } $ipad ^= $key; $opad ^= $key; return 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; } } // Define if (!function_exists('hash')) { function hash($algo, $data, $raw_output = false) { return php_compat_hash($algo, $data, $raw_output); } } //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.0070.00716.75
8.3.50.0120.00522.90
8.3.40.0120.00319.04
8.3.30.0140.00019.34
8.3.20.0040.00420.31
8.3.10.0030.00623.45
8.3.00.0060.00319.50
8.2.180.0090.01316.88
8.2.170.0120.00322.96
8.2.160.0070.01120.64
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0090.00026.16
8.2.120.0080.00020.95
8.2.110.0030.00720.86
8.2.100.0080.00418.03
8.2.90.0000.00819.30
8.2.80.0000.00817.97
8.2.70.0040.00417.75
8.2.60.0080.00018.05
8.2.50.0040.00418.10
8.2.40.0070.00418.09
8.2.30.0080.00018.31
8.2.20.0080.00017.93
8.2.10.0000.00818.15
8.2.00.0040.00417.84
8.1.280.0070.01425.92
8.1.270.0040.00423.97
8.1.260.0050.00326.35
8.1.250.0050.00228.09
8.1.240.0060.00324.02
8.1.230.0060.00617.75
8.1.220.0030.00717.91
8.1.210.0000.00818.77
8.1.200.0030.00617.46
8.1.190.0080.00017.48
8.1.180.0000.00818.10
8.1.170.0040.00418.78
8.1.160.0040.00422.11
8.1.150.0000.00718.97
8.1.140.0000.00817.55
8.1.130.0080.00017.85
8.1.120.0050.00317.69
8.1.110.0050.00317.66
8.1.100.0000.00717.54
8.1.90.0000.00717.64
8.1.80.0030.00517.70
8.1.70.0000.00817.61
8.1.60.0030.00617.61
8.1.50.0040.00417.63
8.1.40.0040.00417.62
8.1.30.0040.00417.74
8.1.20.0030.00517.81
8.1.10.0080.00017.69
8.1.00.0040.00417.63
8.0.300.0090.00018.77
8.0.290.0040.00416.88
8.0.280.0070.00018.48
8.0.270.0050.00217.29
8.0.260.0050.00317.42
8.0.250.0030.00317.10
8.0.240.0070.00017.10
8.0.230.0040.00417.23
8.0.220.0030.00317.13
8.0.210.0040.00417.01
8.0.200.0040.00417.09
8.0.190.0090.00017.16
8.0.180.0040.00417.06
8.0.170.0000.00816.93
8.0.160.0070.00017.08
8.0.150.0040.00417.05
8.0.140.0000.00716.97
8.0.130.0000.00613.51
8.0.120.0110.00115.22
8.0.110.0060.00415.24
8.0.100.0090.00115.26
8.0.90.0060.00615.18
8.0.80.0120.00815.29
8.0.70.0020.00915.24
8.0.60.0060.00415.21
8.0.50.0020.00915.30
8.0.30.0110.00815.95
8.0.20.0120.00716.12
8.0.10.0080.00215.30
8.0.00.0090.00615.86
7.4.330.0030.00315.07
7.4.320.0030.00316.48
7.4.300.0040.00416.62
7.4.290.0040.00416.77
7.4.280.0000.00816.68
7.4.270.0050.00316.79
7.4.260.0000.00716.61
7.4.250.0040.00515.13
7.4.240.0070.00315.61
7.4.230.0080.00415.07
7.4.220.0110.00815.13
7.4.210.0090.00515.05
7.4.200.0070.00315.02
7.4.190.0090.00313.45
7.4.180.0030.00513.45
7.4.160.0080.00415.00
7.4.150.0090.00715.41
7.4.140.0090.00716.37
7.4.130.0120.00215.54
7.4.120.0080.01015.53
7.4.110.0100.00814.96
7.4.100.0100.00815.01
7.4.90.0090.00715.01
7.4.80.0120.00816.36
7.4.70.0130.00214.97
7.4.60.0070.00814.98
7.4.50.0060.00314.89
7.4.40.0080.00614.89
7.4.30.0060.00815.01
7.4.20.0090.00213.34
7.4.10.0060.00413.33
7.4.00.0030.01014.26
7.3.330.0040.00413.54
7.3.320.0000.00513.54
7.3.310.0030.00514.88
7.3.300.0050.00214.97
7.3.290.0080.00614.96
7.3.280.0070.00815.72
7.3.270.0070.00615.45
7.3.260.0090.00514.97
7.3.250.0130.00215.50
7.3.240.0120.00115.12
7.3.230.0040.00914.97
7.3.220.0090.00013.60
7.3.210.0050.00814.96
7.3.200.0050.00816.45
7.3.190.0080.01015.03
7.3.180.0070.00715.14
7.3.170.0110.00614.93
7.3.160.0080.00615.15
7.3.150.0000.00813.40
7.3.140.0040.00413.48
7.3.130.0000.00613.48
7.3.120.0000.00613.48
7.3.110.0000.00613.46
7.3.100.0000.00613.40
7.3.90.0000.00713.67
7.3.80.0030.00313.30
7.3.70.0000.00613.40
7.3.60.0070.00013.63
7.3.50.0060.00013.57
7.3.40.0030.00313.56
7.3.30.0030.00313.55
7.3.20.0000.00615.25
7.3.10.0030.00815.84
7.3.00.0050.00516.01
7.2.340.0040.00813.56
7.2.330.0140.00315.18
7.2.320.0110.00715.06
7.2.310.0090.00615.13
7.2.300.0090.00515.28
7.2.290.0110.00915.06
7.2.280.0100.00613.40
7.2.270.0110.00313.41
7.2.260.0100.00413.50
7.2.250.0100.00513.41
7.2.240.0120.00013.52
7.2.230.0120.00013.46
7.2.220.0120.00013.54
7.2.210.0050.00813.66
7.2.200.0140.00013.79
7.2.190.0120.00013.66
7.2.180.0090.00513.73
7.2.170.0110.00313.67
7.2.160.0100.00213.68
7.2.150.0080.00515.39
7.2.140.0110.00215.43
7.2.130.0100.00516.23
7.2.120.0080.00616.23
7.2.110.0070.00716.18
7.2.100.0100.00516.13
7.2.90.0070.00916.22
7.2.80.0080.00816.42
7.2.70.0040.01116.32
7.2.60.0040.01116.38
7.2.50.0040.01016.09
7.2.40.0100.00316.11
7.2.30.0080.00816.28
7.2.20.0090.00416.29
7.2.10.0090.00716.26
7.2.00.0060.00917.39
7.1.330.0080.00514.36
7.1.320.0130.00014.29
7.1.310.0090.00314.54
7.1.300.0090.00414.28
7.1.290.0140.00014.32
7.1.280.0080.00514.39
7.1.270.0110.00214.29
7.1.260.0060.00614.12
7.1.250.0040.01015.02
7.1.240.0080.00414.35
7.1.230.0070.00714.46
7.1.220.0080.00614.49
7.1.210.0110.00314.45
7.1.200.0030.00815.13
7.1.190.0050.00914.20
7.1.180.0090.00314.33
7.1.170.0120.00014.43
7.1.160.0040.00914.38
7.1.150.0070.00614.39
7.1.140.0130.00014.27
7.1.130.0100.00314.37
7.1.120.0130.00014.48
7.1.110.0090.00414.46
7.1.100.0050.00716.25
7.1.90.0060.00714.24
7.1.80.0070.00714.25
7.1.70.0070.00415.77
7.1.60.0150.00616.94
7.1.50.0050.01015.79
7.1.40.0090.00314.45
7.1.30.0110.00014.33
7.1.20.0120.00014.39
7.1.10.0110.00314.39
7.1.00.0080.03818.43
7.0.330.0270.00014.20
7.0.320.0060.00614.27
7.0.310.0090.00314.07
7.0.300.0070.00314.06
7.0.290.0060.00414.07
7.0.280.0000.01014.17
7.0.270.0060.00314.23
7.0.260.0140.00614.07
7.0.250.0110.00014.38
7.0.240.0030.01014.33
7.0.230.0060.00314.34
7.0.220.0060.00614.40
7.0.210.0080.00414.39
7.0.200.0050.00515.59
7.0.190.0080.00414.25
7.0.180.0090.00414.24
7.0.170.0040.00814.29
7.0.160.0100.00314.16
7.0.150.0080.00414.34
7.0.140.0050.04018.19
7.0.130.0080.00314.36
7.0.120.0120.00014.38
7.0.110.0080.00414.30
7.0.100.0050.03717.20
7.0.90.0160.04117.13
7.0.80.0070.04017.04
7.0.70.0090.03517.10
7.0.60.0040.04417.11
7.0.50.0110.03917.33
7.0.40.0060.03617.14
7.0.30.0090.04217.10
7.0.20.0100.03817.12
7.0.10.0060.03717.10
7.0.00.0090.03917.04
5.6.400.0100.00212.88
5.6.390.0070.00713.06
5.6.380.0090.00313.07
5.6.370.0080.00613.04
5.6.360.0080.00512.89
5.6.350.0050.00812.71
5.6.340.0070.00712.89
5.6.330.0090.00512.73
5.6.320.0140.00012.99
5.6.310.0050.01012.92
5.6.300.0110.00312.66
5.6.290.0090.00212.90
5.6.280.0090.03717.05
5.6.270.0080.00412.92
5.6.260.0100.00312.77
5.6.250.0100.03516.78
5.6.240.0100.04016.94
5.6.230.0030.04716.82
5.6.220.0080.02516.73
5.6.210.0050.02716.84
5.6.200.0090.02017.19
5.6.190.0080.02516.98
5.6.180.0120.04017.09
5.6.170.0070.04217.17
5.6.160.0080.04517.09
5.6.150.0070.04417.09
5.6.140.0080.03616.97
5.6.130.0100.03017.14
5.6.120.0150.04317.11
5.6.110.0130.03717.09
5.6.100.0080.02717.00
5.6.90.0100.04216.87
5.6.80.0150.03216.69
5.6.70.0110.02316.72
5.6.60.0050.03216.85
5.6.50.0050.03416.63
5.6.40.0070.03116.74
5.6.30.0050.04216.69
5.6.20.0070.04516.61
5.6.10.0070.02416.65
5.6.00.0070.02716.66
5.5.380.0030.04616.76
5.5.370.0090.04216.90
5.5.360.0070.04416.67
5.5.350.0070.03116.74
5.5.340.0090.03616.93
5.5.330.0100.02316.94
5.5.320.0070.03416.99
5.5.310.0050.03116.95
5.5.300.0090.04516.73
5.5.290.0060.03716.90
5.5.280.0170.03516.91
5.5.270.0130.03016.87
5.5.260.0070.03816.91
5.5.250.0100.04316.87
5.5.240.0070.03116.61
5.5.230.0110.02816.65
5.5.220.0090.03516.59
5.5.210.0080.03716.67
5.5.200.0110.03816.56
5.5.190.0090.03816.47
5.5.180.0120.03716.64
5.5.170.0040.00812.88
5.5.160.0100.02016.64
5.5.150.0050.02416.49
5.5.140.0090.02216.41
5.5.130.0070.02316.51
5.5.120.0060.02216.50
5.5.110.0100.01816.28
5.5.100.0050.02416.66
5.5.90.0050.02316.62
5.5.80.0110.01616.49
5.5.70.0060.02216.62
5.5.60.0100.01816.46
5.5.50.0070.02116.61
5.5.40.0030.02316.52
5.5.30.0060.02216.59
5.5.20.0060.02216.46
5.5.10.0060.02116.54
5.5.00.0070.02816.52
5.4.450.0070.03116.02
5.4.440.0110.02316.15
5.4.430.0080.03916.11
5.4.420.0140.02016.28
5.4.410.0140.03116.14
5.4.400.0070.02915.83
5.4.390.0070.03515.82
5.4.380.0150.03215.80
5.4.370.0100.03515.94
5.4.360.0080.02816.00
5.4.350.0050.04515.93
5.4.340.0080.04015.99
5.4.330.0040.00912.80
5.4.320.0060.02216.04
5.4.310.0080.02015.94
5.4.300.0060.02015.93
5.4.290.0080.02015.89
5.4.280.0060.01815.87
5.4.270.0050.02315.88
5.4.260.0080.01915.99
5.4.250.0100.01515.83
5.4.240.0060.02015.88
5.4.230.0070.01715.76
5.4.220.0080.02815.86
5.4.210.0060.02015.84
5.4.200.0050.02315.94
5.4.190.0040.02415.85
5.4.180.0080.02615.83
5.4.170.0040.03915.90
5.4.160.0030.02315.88
5.4.150.0090.01815.88
5.4.140.0060.02214.73
5.4.130.0070.01814.58
5.4.120.0020.02414.61
5.4.110.0080.01814.66
5.4.100.0050.02114.63
5.4.90.0030.02014.63
5.4.80.0020.02414.58
5.4.70.0030.02314.58
5.4.60.0020.02114.62
5.4.50.0060.01814.65
5.4.40.0070.01814.68
5.4.30.0040.02214.69
5.4.20.0080.01814.59
5.4.10.0070.02014.57
5.4.00.0020.02314.29

preferences:
45.81 ms | 401 KiB | 5 Q