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' => 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 = 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/1uH6OR0 if (!function_exists('json_encode')) { function 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[] = json_encode($v); return '[' . join(',', $result) . ']'; } else { foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v); return '{' . join(',', $result) . '}'; } } } //http://bit.ly/1q8GwII if (!function_exists('http_build_query')) { function 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.88
8.3.50.0070.00922.89
8.3.40.0040.01118.81
8.3.30.0070.00719.16
8.3.20.0060.00320.38
8.3.10.0050.00323.65
8.3.00.0040.00419.50
8.2.180.0120.00316.88
8.2.170.0140.00022.96
8.2.160.0040.01121.07
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00020.95
8.2.110.0090.00020.69
8.2.100.0110.00018.16
8.2.90.0100.00019.48
8.2.80.0000.00917.97
8.2.70.0000.01217.50
8.2.60.0040.00418.05
8.2.50.0080.00018.07
8.2.40.0090.00418.09
8.2.30.0030.00518.18
8.2.20.0050.00317.92
8.2.10.0000.00718.20
8.2.00.0000.01017.78
8.1.280.0070.01025.92
8.1.270.0040.00423.70
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0090.00021.92
8.1.230.0080.00419.27
8.1.220.0030.00617.78
8.1.210.0060.00318.77
8.1.200.0070.00317.35
8.1.190.0080.00017.60
8.1.180.0080.00019.01
8.1.170.0040.00418.91
8.1.160.0030.00622.02
8.1.150.0040.00418.91
8.1.140.0040.00417.47
8.1.130.0030.00317.97
8.1.120.0040.00417.57
8.1.110.0080.00017.62
8.1.100.0070.00017.55
8.1.90.0040.00417.59
8.1.80.0000.00717.63
8.1.70.0030.00317.61
8.1.60.0050.00517.59
8.1.50.0090.00017.53
8.1.40.0050.00317.60
8.1.30.0050.00317.62
8.1.20.0000.00817.63
8.1.10.0030.00617.64
8.1.00.0000.00917.51
8.0.300.0000.00918.77
8.0.290.0000.00816.88
8.0.280.0030.00318.57
8.0.270.0050.00517.29
8.0.260.0000.00717.32
8.0.250.0000.00717.16
8.0.240.0040.00417.16
8.0.230.0000.00717.17
8.0.220.0040.00417.02
8.0.210.0050.00217.13
8.0.200.0000.00817.16
8.0.190.0000.00817.02
8.0.180.0040.00416.98
8.0.170.0060.00317.11
8.0.160.0000.00717.04
8.0.150.0050.00217.01
8.0.140.0040.00416.98
8.0.130.0070.00013.48
8.0.120.0040.00417.01
8.0.110.0040.00417.09
8.0.100.0070.00017.01
8.0.90.0040.00416.98
8.0.80.0060.01617.08
8.0.70.0000.00817.13
8.0.60.0030.00617.10
8.0.50.0040.00416.94
8.0.30.0120.01117.31
8.0.20.0090.01017.40
8.0.10.0040.00417.01
8.0.00.0100.00817.04
7.4.330.0050.00015.15
7.4.320.0060.00016.68
7.4.300.0030.00316.71
7.4.290.0050.00216.63
7.4.280.0040.00416.60
7.4.270.0030.00316.60
7.4.260.0020.00516.62
7.4.250.0050.00316.50
7.4.240.0040.00316.62
7.4.230.0000.00716.64
7.4.220.0120.00616.74
7.4.210.0070.01016.63
7.4.200.0030.00516.48
7.4.160.0080.00816.61
7.4.150.0140.00317.40
7.4.140.0110.00817.86
7.4.130.0130.00416.74
7.4.120.0030.01416.64
7.4.110.0150.00616.80
7.4.100.0100.00716.59
7.4.90.0130.00616.61
7.4.80.0070.01119.39
7.4.70.0120.01216.48
7.4.60.0070.01116.74
7.4.50.0040.00416.26
7.4.40.0060.01216.61
7.4.30.0060.00916.62
7.4.00.0030.01015.20
7.3.330.0080.00013.39
7.3.320.0030.00313.24
7.3.310.0040.00416.61
7.3.300.0000.00816.46
7.3.290.0060.01516.50
7.3.280.0120.00416.53
7.3.270.0150.00317.40
7.3.260.0080.01416.61
7.3.250.0100.00716.69
7.3.240.0120.00616.67
7.3.230.0070.01716.56
7.3.210.0090.00916.72
7.3.200.0120.00619.39
7.3.190.0030.00216.64
7.3.180.0060.01216.57
7.3.170.0100.00716.70
7.3.160.0080.00816.72
7.2.330.0070.01116.76
7.2.320.0040.01516.95
7.2.310.0070.01016.78
7.2.300.0130.00416.73
7.2.290.0120.00616.62
7.2.60.0040.01117.01
7.2.00.0090.00619.20
7.1.200.0090.00415.79
7.1.100.0000.01018.41
7.1.70.0020.00516.98
7.1.60.0040.01419.40
7.1.50.0000.02317.11
7.1.00.0000.07722.37
7.0.200.0000.01016.54
7.0.140.0000.07722.00
7.0.90.0170.06719.95
7.0.80.0000.05020.04
7.0.70.0600.07319.96
7.0.60.0370.06319.99
7.0.50.0770.07720.32
7.0.40.0130.07720.19
7.0.30.0030.08020.18
7.0.20.0130.07320.11
7.0.10.0070.08020.07
7.0.00.0170.07020.18
5.6.280.0030.07320.92
5.6.240.0230.06020.69
5.6.230.0000.08720.58
5.6.220.0130.08020.78
5.6.210.0100.08320.70
5.6.200.0100.08321.20
5.6.190.0100.08321.23
5.6.180.0070.04321.11
5.6.170.0100.08321.10
5.6.160.0170.07321.06
5.6.150.0130.07021.11
5.6.140.0100.08021.11
5.6.130.0030.08321.07
5.6.120.0130.06021.09
5.6.110.0000.10321.01
5.6.100.0070.08321.11
5.6.90.0000.07320.99
5.6.80.0070.07720.47
5.6.70.0070.05320.39
5.6.60.0130.07020.36
5.6.50.0170.07720.57
5.6.40.0100.06320.43
5.6.30.0030.06320.48
5.6.20.0030.07720.54
5.6.10.0100.04020.49
5.6.00.0100.07320.36
5.5.380.0170.06720.57
5.5.370.0100.08320.43
5.5.360.0100.08020.41
5.5.350.0030.08020.42
5.5.340.0070.08320.95
5.5.330.0070.07720.96
5.5.320.0070.04320.81
5.5.310.0000.08320.92
5.5.300.0100.08020.89
5.5.290.0130.06020.82
5.5.280.0100.04720.98
5.5.270.0100.08020.94
5.5.260.0030.04720.93
5.5.250.0130.08720.66
5.5.240.0100.05020.32
5.5.230.0100.07720.33
5.5.220.0170.07020.23
5.5.210.0200.06020.28
5.5.200.0230.06320.20
5.5.190.0030.08020.18
5.5.180.0130.07720.28
5.5.160.0000.05320.33
5.5.150.0030.05720.30
5.5.140.0070.05720.29
5.5.130.0130.06720.31
5.5.120.0100.05720.29
5.5.110.0030.08020.17
5.5.100.0000.05720.23
5.5.90.0030.08320.21
5.5.80.0130.07020.09
5.5.70.0000.07320.11
5.5.60.0070.07320.20
5.5.50.0100.07020.21
5.5.40.0070.08020.01
5.5.30.0100.08020.21
5.5.20.0100.07020.17
5.5.10.0100.07020.06
5.5.00.0130.07320.13
5.4.450.0100.06719.36
5.4.440.0070.04719.26
5.4.430.0130.07019.27
5.4.420.0070.08019.37
5.4.410.0130.07719.34
5.4.400.0070.06319.10
5.4.390.0000.08018.95
5.4.380.0100.07718.84
5.4.370.0130.07319.21
5.4.360.0100.06319.18
5.4.350.0030.08019.09
5.4.340.0000.08319.05
5.4.320.0030.06719.04
5.4.310.0100.07319.05
5.4.300.0100.07319.15
5.4.290.0100.08319.20
5.4.280.0170.07318.85
5.4.270.0030.08018.85
5.4.260.0070.06719.12
5.4.250.0070.07019.20
5.4.240.0130.07019.19
5.4.230.0100.08019.03
5.4.220.0030.08719.20
5.4.210.0070.04719.13
5.4.200.0100.05018.94
5.4.190.0100.04719.08
5.4.180.0070.07019.02
5.4.170.0170.06319.11
5.4.160.0030.07719.16
5.4.150.0100.05018.93
5.4.140.0070.07316.20
5.4.130.0070.07016.50
5.4.120.0200.05716.46
5.4.110.0130.06016.38
5.4.100.0130.06316.56
5.4.90.0070.05016.32
5.4.80.0070.07016.56
5.4.70.0070.07016.47
5.4.60.0070.07316.54
5.4.50.0030.07016.54
5.4.40.0070.07716.54
5.4.30.0200.04716.37
5.4.20.0100.06716.45
5.4.10.0100.06016.30
5.4.00.0100.07315.79

preferences:
36.01 ms | 401 KiB | 5 Q