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 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[] = 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 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.0120.00916.86
8.3.50.0150.00322.90
8.3.40.0110.00419.14
8.3.30.0180.00319.22
8.3.20.0080.00020.16
8.3.10.0000.00823.54
8.3.00.0030.00519.38
8.2.180.0090.00616.63
8.2.170.0000.01522.96
8.2.160.0060.00820.51
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0060.00326.16
8.2.120.0040.00421.02
8.2.110.0100.00019.32
8.2.100.0040.00817.97
8.2.90.0040.00418.47
8.2.80.0040.00418.29
8.2.70.0050.00518.04
8.2.60.0080.00018.34
8.2.50.0050.00318.10
8.2.40.0080.00019.40
8.2.30.0030.00518.28
8.2.20.0040.00417.95
8.2.10.0000.00918.29
8.2.00.0050.00317.81
8.1.280.0070.00725.92
8.1.270.0030.00623.70
8.1.260.0050.00326.35
8.1.250.0000.00728.09
8.1.240.0090.00022.11
8.1.230.0090.00321.04
8.1.220.0030.00617.90
8.1.210.0080.00018.77
8.1.200.0030.00617.48
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0050.00318.84
8.1.160.0000.00718.92
8.1.150.0060.00318.97
8.1.140.0040.00417.64
8.1.130.0000.00717.93
8.1.120.0000.00717.64
8.1.110.0000.00917.61
8.1.100.0000.00817.52
8.1.90.0040.00417.64
8.1.80.0000.00817.64
8.1.70.0040.00417.59
8.1.60.0040.00417.75
8.1.50.0000.00817.63
8.1.40.0050.00317.55
8.1.30.0040.00417.66
8.1.20.0040.00417.77
8.1.10.0000.00817.62
8.1.00.0040.00417.56
8.0.300.0000.00820.15
8.0.290.0090.00017.00
8.0.280.0030.00318.53
8.0.270.0000.00717.26
8.0.260.0000.00717.35
8.0.250.0030.00317.16
8.0.240.0030.00617.16
8.0.230.0000.00717.12
8.0.220.0030.00317.06
8.0.210.0030.00317.16
8.0.200.0040.00417.21
8.0.190.0000.00817.10
8.0.180.0000.00717.11
8.0.170.0030.00516.98
8.0.160.0040.00416.96
8.0.150.0030.00516.88
8.0.140.0000.00716.79
8.0.130.0030.00313.44
8.0.120.0030.00516.97
8.0.110.0000.00817.15
8.0.100.0080.00017.02
8.0.90.0000.00816.98
8.0.80.0160.00617.11
8.0.70.0040.00417.10
8.0.60.0040.00417.17
8.0.50.0020.00517.09
8.0.30.0090.01117.25
8.0.20.0080.01617.40
8.0.10.0080.00017.17
8.0.00.0090.00917.07
7.4.330.0000.00515.20
7.4.320.0050.00216.74
7.4.300.0030.00616.72
7.4.290.0070.00016.58
7.4.280.0000.00816.71
7.4.270.0000.00716.61
7.4.260.0000.00716.70
7.4.250.0030.00516.60
7.4.240.0020.00616.61
7.4.230.0000.00716.80
7.4.220.0070.01116.70
7.4.210.0070.01616.62
7.4.200.0040.00416.78
7.4.160.0030.01316.51
7.4.150.0060.01217.40
7.4.140.0090.01017.86
7.4.130.0110.00816.73
7.4.120.0100.00816.78
7.4.110.0140.00716.68
7.4.100.0060.01316.64
7.4.90.0090.00916.60
7.4.80.0130.00619.39
7.4.70.0110.00816.83
7.4.60.0100.00716.54
7.4.50.0060.00316.80
7.4.40.0150.00816.59
7.4.30.0120.00616.60
7.4.10.0100.00714.78
7.4.00.0060.00914.82
7.3.330.0000.00713.49
7.3.320.0000.00513.52
7.3.310.0070.00016.48
7.3.300.0040.00416.54
7.3.290.0000.01416.51
7.3.280.0080.00716.50
7.3.270.0120.00617.40
7.3.260.0100.01016.66
7.3.250.0100.00716.73
7.3.240.0150.00316.76
7.3.230.0000.01916.71
7.3.210.0120.00516.70
7.3.200.0090.00919.39
7.3.190.0190.00416.71
7.3.180.0090.00616.66
7.3.170.0130.00416.57
7.3.160.0030.01216.61
7.3.130.0030.01315.08
7.3.120.0110.00314.97
7.3.110.0090.00915.16
7.3.100.0060.00614.77
7.3.90.0060.00914.81
7.3.80.0080.00615.12
7.3.70.0030.00914.89
7.3.60.0070.00715.10
7.3.50.0090.00615.02
7.3.40.0060.00914.72
7.3.30.0110.00415.02
7.3.20.0100.00616.48
7.3.10.0060.00916.71
7.3.00.0030.01216.89
7.2.330.0180.00016.62
7.2.320.0090.00916.91
7.2.310.0090.00916.97
7.2.300.0090.01516.68
7.2.290.0160.00916.85
7.2.260.0170.00315.35
7.2.250.0150.00415.21
7.2.240.0060.00915.36
7.2.230.0130.00315.43
7.2.220.0030.01215.41
7.2.210.0030.01215.33
7.2.200.0040.01115.28
7.2.190.0070.00415.27
7.2.180.0000.01615.30
7.2.170.0060.00614.89
7.2.160.0090.00615.02
7.2.150.0100.01016.98
7.2.140.0090.00617.03
7.2.130.0070.00716.80
7.2.120.0140.00016.88
7.2.110.0030.01417.09
7.2.100.0090.00316.74
7.2.90.0100.00616.95
7.2.80.0040.01417.06
7.2.70.0070.01117.09
7.2.60.0070.01017.07
7.2.50.0040.01116.98
7.2.40.0070.01116.98
7.2.30.0040.01216.93
7.2.20.0070.00716.99
7.2.10.0040.01116.99
7.2.00.0050.01018.30
7.1.330.0070.00715.95
7.1.320.0030.01015.65
7.1.310.0070.00715.92
7.1.300.0040.00715.89
7.1.290.0110.00315.94
7.1.280.0070.00715.71
7.1.270.0000.01415.97
7.1.260.0080.00415.91
7.1.250.0040.00715.91
7.1.240.0000.01315.98
7.1.230.0070.00715.62
7.1.220.0030.01015.54
7.1.210.0080.00815.68
7.1.200.0060.00615.59
7.1.190.0030.01415.79
7.1.180.0120.00315.82
7.1.170.0040.00815.84
7.1.160.0000.01715.88
7.1.150.0070.00715.96
7.1.140.0030.01315.93
7.1.130.0060.00915.86
7.1.120.0110.00315.78
7.1.110.0030.00816.04
7.1.100.0030.01116.97
7.1.90.0110.00715.77
7.1.80.0000.01015.84
7.1.70.0030.00816.67
7.1.60.0070.01017.60
7.1.50.0030.01216.52
7.1.40.0030.01315.86
7.1.30.0130.00015.66
7.1.20.0070.01015.73
7.1.10.0040.01115.88
7.1.00.0030.04319.00
7.0.330.0030.00615.22
7.0.320.0000.01015.57
7.0.310.0060.00615.51
7.0.300.0100.00315.42
7.0.290.0090.00615.61
7.0.280.0000.01415.23
7.0.270.0080.00815.51
7.0.260.0000.01015.50
7.0.250.0060.00315.40
7.0.240.0070.00715.61
7.0.230.0030.00915.31
7.0.220.0030.00715.32
7.0.210.0040.01115.41
7.0.200.0130.00216.22
7.0.190.0130.00315.27
7.0.180.0030.00615.23
7.0.170.0000.01015.69
7.0.160.0030.00715.54
7.0.150.0060.00615.59
7.0.140.0040.04018.68
7.0.130.0000.00915.62
7.0.120.0000.01315.48
7.0.110.0090.00415.59
7.0.100.0040.00815.49
7.0.90.0100.04617.61
7.0.80.0050.03017.71
7.0.70.0120.03917.77
7.0.60.0150.03617.79
7.0.50.0080.02518.04
7.0.40.0130.04316.85
7.0.30.0050.04216.87
7.0.20.0060.03916.82
7.0.10.0070.03016.84
7.0.00.0130.04216.77
5.6.400.0120.00314.56
5.6.390.0060.00614.84
5.6.380.0000.01414.63
5.6.370.0030.01014.76
5.6.360.0000.01514.98
5.6.350.0070.01014.41
5.6.340.0030.01014.59
5.6.330.0070.00714.82
5.6.320.0060.00914.73
5.6.310.0100.00714.42
5.6.300.0040.01114.78
5.6.290.0060.00914.76
5.6.280.0070.04217.93
5.6.270.0070.00714.53
5.6.260.0090.00614.49
5.6.250.0060.00614.67
5.6.240.0070.04417.70
5.6.230.0050.04617.68
5.6.220.0070.02317.75
5.6.210.0110.04017.65
5.6.200.0030.03617.79
5.6.190.0070.04818.02
5.6.180.0130.04017.85
5.6.170.0080.04317.82
5.6.160.0080.04117.89
5.6.150.0070.04817.68
5.6.140.0100.04217.68
5.6.130.0110.04017.76
5.6.120.0030.04517.91
5.6.110.0030.03217.82
5.6.100.0090.04017.79
5.6.90.0050.03917.89
5.6.80.0110.03117.46
5.6.70.0150.03917.45
5.6.60.0080.03517.49
5.6.50.0090.04417.35
5.6.40.0030.04017.31
5.6.30.0050.03417.62
5.6.20.0110.04317.48
5.6.10.0050.04417.56
5.6.00.0090.03717.59
5.5.380.0070.04217.63
5.5.370.0100.04317.60
5.5.360.0120.03917.57
5.5.350.0090.04317.52
5.5.340.0080.04217.63
5.5.330.0120.04017.80
5.5.320.0050.04517.55
5.5.310.0070.04517.70
5.5.300.0070.02717.56
5.5.290.0050.04417.74
5.5.280.0080.04517.74
5.5.270.0110.03817.65
5.5.260.0050.04717.87
5.5.250.0050.02917.57
5.5.240.0020.03017.38
5.5.230.0110.04017.29
5.5.220.0120.03817.37
5.5.210.0080.04417.34
5.5.200.0050.02617.43
5.5.190.0070.04317.40
5.5.180.0030.03317.42
5.5.170.0070.01014.36
5.5.160.0120.03817.33
5.5.150.0060.03817.46
5.5.140.0110.04017.45
5.5.130.0100.04317.26
5.5.120.0060.04217.09
5.5.110.0090.04017.41
5.5.100.0090.04017.08
5.5.90.0120.03817.16
5.5.80.0130.03817.25
5.5.70.0050.04417.24
5.5.60.0090.04017.18
5.5.50.0070.03217.33
5.5.40.0070.03317.21
5.5.30.0010.03917.32
5.5.20.0050.03517.35
5.5.10.0100.04117.40
5.5.00.0080.04217.17
5.4.450.0030.04516.43
5.4.440.0130.03816.32
5.4.430.0080.04016.35
5.4.420.0070.04016.39
5.4.410.0060.02916.33
5.4.400.0120.02116.31
5.4.390.0050.04216.24
5.4.380.0030.04216.24
5.4.370.0070.03916.23
5.4.360.0060.04016.28
5.4.350.0020.02616.23
5.4.340.0080.03816.23
5.4.330.0030.00613.43
5.4.320.0090.03416.27
5.4.310.0070.04016.23
5.4.300.0090.02316.28
5.4.290.0050.04416.19
5.4.280.0100.02316.17
5.4.270.0070.02316.19
5.4.260.0030.04716.18
5.4.250.0060.02416.18
5.4.240.0030.04016.31
5.4.230.0120.03716.30
5.4.220.0070.03016.23
5.4.210.0110.03516.23
5.4.200.0140.02116.25
5.4.190.0070.04216.13
5.4.180.0130.03516.22
5.4.170.0000.03716.16
5.4.160.0030.02516.32
5.4.150.0080.04016.18
5.4.140.0050.04014.94
5.4.130.0050.04114.93
5.4.120.0080.03014.94
5.4.110.0080.03714.94
5.4.100.0050.02714.99
5.4.90.0020.03314.93
5.4.80.0080.02314.91
5.4.70.0040.02514.97
5.4.60.0070.03314.89
5.4.50.0050.04014.91
5.4.40.0060.03814.91
5.4.30.0080.03614.86
5.4.20.0050.03814.90
5.4.10.0110.03914.93
5.4.00.0050.02914.64

preferences:
44.37 ms | 401 KiB | 5 Q