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 = 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.40.0110.00418.78
8.3.30.0090.00619.19
8.3.20.0080.00020.34
8.3.10.0070.00023.70
8.3.00.0040.00419.50
8.2.170.0090.00622.96
8.2.160.0070.00720.64
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00021.04
8.2.110.0030.00620.56
8.2.100.0040.00818.16
8.2.90.0060.00319.22
8.2.80.0050.00317.97
8.2.70.0050.00517.75
8.2.60.0040.00418.16
8.2.50.0040.00418.07
8.2.40.0060.00618.09
8.2.30.0050.00318.21
8.2.20.0000.00817.91
8.2.10.0000.00818.07
8.2.00.0000.00817.90
8.1.270.0050.00323.64
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.35
8.1.230.0060.00619.22
8.1.220.0040.00417.89
8.1.210.0050.00318.77
8.1.200.0080.00317.48
8.1.190.0050.00317.36
8.1.180.0000.00918.10
8.1.170.0000.00818.73
8.1.160.0000.00822.05
8.1.150.0000.00818.80
8.1.140.0000.00717.54
8.1.130.0040.00417.94
8.1.120.0050.00317.47
8.1.110.0030.00617.49
8.1.100.0000.00717.54
8.1.90.0030.00317.50
8.1.80.0000.00817.52
8.1.70.0000.00717.45
8.1.60.0040.00417.63
8.1.50.0000.00817.65
8.1.40.0000.00817.57
8.1.30.0050.00317.55
8.1.20.0000.00917.66
8.1.10.0030.00617.57
8.1.00.0040.00417.50
8.0.300.0070.00018.77
8.0.290.0050.00316.88
8.0.280.0000.00718.53
8.0.270.0030.00517.34
8.0.260.0000.00617.32
8.0.250.0050.00216.96
8.0.240.0040.00417.05
8.0.230.0050.00317.07
8.0.220.0000.00717.04
8.0.210.0070.00016.83
8.0.200.0080.00017.09
8.0.190.0050.00516.95
8.0.180.0040.00417.02
8.0.170.0060.00317.09
8.0.160.0000.00716.96
8.0.150.0030.00516.98
8.0.140.0040.00416.83
8.0.130.0060.00013.41
8.0.120.0090.00017.00
8.0.110.0050.00316.84
8.0.100.0040.00417.09
8.0.90.0000.00717.06
8.0.80.0100.01316.99
8.0.70.0000.00816.88
8.0.60.0040.00417.00
8.0.50.0000.00716.85
8.0.30.0090.01317.21
8.0.20.0110.00917.40
8.0.10.0060.00317.03
8.0.00.0090.00916.81
7.4.330.0030.00315.00
7.4.320.0030.00316.62
7.4.300.0030.00316.62
7.4.290.0040.00416.73
7.4.280.0030.00516.58
7.4.270.0000.00716.71
7.4.260.0020.00516.59
7.4.250.0000.00816.63
7.4.240.0030.00516.66
7.4.230.0030.00316.61
7.4.220.0100.00716.57
7.4.210.0030.01416.63
7.4.200.0040.00416.60
7.4.160.0050.01216.45
7.4.150.0160.00317.40
7.4.140.0110.00617.86
7.4.130.0060.01116.70
7.4.120.0070.01216.72
7.4.110.0160.00616.60
7.4.100.0120.00616.58
7.4.90.0070.01116.46
7.4.80.0090.01219.39
7.4.70.0030.02016.55
7.4.60.0060.01216.58
7.4.50.0000.00816.62
7.4.40.0100.00716.56
7.4.30.0030.01216.65
7.4.00.0030.01015.00
7.3.330.0040.00413.47
7.3.320.0050.00013.23
7.3.310.0030.00316.46
7.3.300.0030.00316.51
7.3.290.0110.00416.52
7.3.280.0060.01016.45
7.3.270.0120.00617.40
7.3.260.0070.01716.66
7.3.250.0090.00916.59
7.3.240.0090.00916.44
7.3.230.0100.01416.61
7.3.210.0180.00016.40
7.3.200.0140.00419.39
7.3.190.0080.00516.59
7.3.180.0090.00916.50
7.3.170.0030.02016.61
7.3.160.0090.00616.61
7.3.10.0030.00916.22
7.3.00.0080.00016.49
7.2.330.0060.01216.77
7.2.320.0110.01116.82
7.2.310.0060.01216.89
7.2.300.0100.00716.52
7.2.290.0070.01016.84
7.2.130.0030.01016.84
7.2.120.0060.00616.79
7.2.110.0030.01216.64
7.2.100.0090.00316.87
7.2.90.0070.00716.67
7.2.80.0090.00616.60
7.2.70.0070.00316.57
7.2.60.0090.00416.63
7.2.50.0070.01016.60
7.2.40.0100.00617.00
7.2.30.0070.00716.50
7.2.20.0060.01016.89
7.2.10.0040.01116.90
7.2.00.0080.00718.10
7.1.250.0110.00315.80
7.1.200.0040.00415.57
7.1.100.0080.00618.04
7.1.70.0030.00517.20
7.1.60.0030.02119.40
7.1.50.0100.01016.68
7.1.00.0030.07722.24
7.0.200.0000.01116.80
7.0.140.0000.07721.91
7.0.90.0200.06720.01
7.0.80.0100.07020.00
7.0.70.0100.08020.04
7.0.60.0200.07320.14
7.0.50.0600.05320.40
7.0.40.0170.07020.13
7.0.30.0130.07320.09
7.0.20.0130.03020.05
7.0.10.0030.04020.14
7.0.00.0170.06320.08
5.6.280.0030.07320.88
5.6.240.0030.05720.65
5.6.230.0030.09020.77
5.6.220.0100.07320.79
5.6.210.0070.05720.80
5.6.200.0030.04720.99
5.6.190.0200.06721.06
5.6.180.0100.05020.99
5.6.170.0030.07321.19
5.6.160.0030.06720.93
5.6.150.0030.04321.09
5.6.140.0000.08721.11
5.6.130.0030.09320.98
5.6.120.0070.04321.22
5.6.110.0070.08321.12
5.6.100.0170.06721.21
5.6.90.0100.04021.18
5.6.80.0100.03720.40
5.6.70.0030.05020.45
5.6.60.0030.08720.38
5.6.50.0070.05720.39
5.6.40.0070.06720.50
5.6.30.0070.06320.50
5.6.20.0030.06020.38
5.6.10.0170.07020.35
5.6.00.0070.05020.45
5.5.380.0200.05720.41
5.5.370.0030.05720.59
5.5.360.0070.06020.46
5.5.350.0130.04320.49
5.5.340.0070.06020.70
5.5.330.0070.04320.83
5.5.320.0070.07720.94
5.5.310.0100.08720.94
5.5.300.0030.08020.86
5.5.290.0070.07020.83
5.5.280.0070.08720.93
5.5.270.0130.05720.96
5.5.260.0030.05320.92
5.5.250.0100.07020.75
5.5.240.0070.09320.31
5.5.230.0070.06020.35
5.5.220.0030.04720.29
5.5.210.0130.03320.08
5.5.200.0130.07720.05
5.5.190.0070.07020.23
5.5.180.0100.06720.29
5.5.160.0100.08020.32
5.5.150.0070.04320.30
5.5.140.0070.04320.29
5.5.130.0100.05320.27
5.5.120.0030.06720.15
5.5.110.0070.04720.17
5.5.100.0100.06320.13
5.5.90.0130.03020.03
5.5.80.0070.05320.21
5.5.70.0030.04320.14
5.5.60.0130.06019.99
5.5.50.0030.04020.17
5.5.40.0130.02720.05
5.5.30.0070.07320.12
5.5.20.0000.08320.19
5.5.10.0070.07320.07
5.5.00.0030.06720.14
5.4.450.0070.07019.38
5.4.440.0070.04719.23
5.4.430.0070.07719.34
5.4.420.0070.06319.55
5.4.410.0070.06019.14
5.4.400.0030.07019.01
5.4.390.0070.08319.16
5.4.380.0030.08018.95
5.4.370.0070.03719.09
5.4.360.0200.06318.85
5.4.350.0070.07318.95
5.4.340.0070.07718.95
5.4.320.0070.07319.05
5.4.310.0030.08019.14
5.4.300.0070.06318.88
5.4.290.0070.05718.87
5.4.280.0030.04718.83
5.4.270.0070.05319.09
5.4.260.0000.04319.16
5.4.250.0100.06019.15
5.4.240.0130.06019.04
5.4.230.0030.03719.08
5.4.220.0000.04319.11
5.4.210.0100.04319.02
5.4.200.0100.05719.11
5.4.190.0000.04318.86
5.4.180.0070.08019.22
5.4.170.0030.05319.20
5.4.160.0070.08019.10
5.4.150.0200.05318.83
5.4.140.0070.07016.44
5.4.130.0000.05016.44
5.4.120.0030.04016.39
5.4.110.0100.07016.45
5.4.100.0030.05716.45
5.4.90.0030.03316.39
5.4.80.0030.07016.36
5.4.70.0070.05716.45
5.4.60.0070.03716.30
5.4.50.0070.07016.47
5.4.40.0030.07016.52
5.4.30.0030.07316.38
5.4.20.0100.06016.36
5.4.10.0000.07716.50
5.4.00.0070.03315.89

preferences:
57.75 ms | 400 KiB | 5 Q