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[] = 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.0140.00016.63
8.3.50.0070.00922.99
8.3.40.0090.00919.05
8.3.30.0070.01419.21
8.3.20.0040.00420.29
8.3.10.0060.00323.48
8.3.00.0040.00419.38
8.2.180.0110.00416.50
8.2.170.0090.00622.96
8.2.160.0070.00720.36
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0030.00526.16
8.2.120.0080.00020.96
8.2.110.0070.00322.25
8.2.100.0090.00317.73
8.2.90.0030.00618.09
8.2.80.0030.00617.97
8.2.70.0040.00417.88
8.2.60.0040.00418.17
8.2.50.0050.00518.07
8.2.40.0000.01118.09
8.2.30.0040.00418.21
8.2.20.0000.00917.86
8.2.10.0040.00418.13
8.2.00.0040.00417.82
8.1.280.0130.00325.92
8.1.270.0050.00323.80
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0070.01522.51
8.1.230.0060.00622.63
8.1.220.0080.00017.91
8.1.210.0000.00819.16
8.1.200.0030.00617.48
8.1.190.0030.00617.60
8.1.180.0040.00418.10
8.1.170.0050.00318.70
8.1.160.0000.01022.18
8.1.150.0040.00418.93
8.1.140.0000.00917.48
8.1.130.0000.00717.92
8.1.120.0070.00017.66
8.1.110.0040.00417.56
8.1.100.0040.00417.62
8.1.90.0070.00017.63
8.1.80.0050.00317.60
8.1.70.0000.00717.60
8.1.60.0030.00617.64
8.1.50.0000.00917.61
8.1.40.0050.00317.64
8.1.30.0030.00617.68
8.1.20.0040.00417.59
8.1.10.0060.00317.63
8.1.00.0030.00617.47
8.0.300.0050.00320.10
8.0.290.0000.00817.00
8.0.280.0050.00318.52
8.0.270.0050.00217.27
8.0.260.0060.00017.38
8.0.250.0030.00317.04
8.0.240.0030.00317.23
8.0.230.0000.00717.12
8.0.220.0070.00017.08
8.0.210.0070.00017.06
8.0.200.0000.00617.07
8.0.190.0060.00317.04
8.0.180.0000.00816.98
8.0.170.0030.00617.13
8.0.160.0080.00017.01
8.0.150.0000.00816.92
8.0.140.0000.00716.90
8.0.130.0000.00613.52
8.0.120.0040.00416.92
8.0.110.0040.00416.87
8.0.100.0040.00416.94
8.0.90.0080.00017.11
8.0.80.0100.00717.03
8.0.70.0040.00416.95
8.0.60.0000.00916.95
8.0.50.0040.00417.04
8.0.30.0170.00317.16
8.0.20.0080.01417.41
8.0.10.0000.00717.16
8.0.00.0040.01316.91
7.4.330.0030.00315.00
7.4.320.0000.00616.70
7.4.300.0000.00616.72
7.4.290.0030.00316.58
7.4.280.0040.00416.45
7.4.270.0030.00516.69
7.4.260.0000.00716.68
7.4.250.0040.00416.74
7.4.240.0030.00516.73
7.4.230.0000.00716.41
7.4.220.0100.01416.67
7.4.210.0130.00316.73
7.4.200.0000.00816.48
7.4.160.0120.00616.62
7.4.150.0110.00717.40
7.4.140.0120.00617.86
7.4.130.0050.01216.52
7.4.120.0040.01316.72
7.4.110.0140.00716.61
7.4.100.0070.01016.75
7.4.90.0150.00616.80
7.4.80.0090.01219.39
7.4.70.0100.00716.51
7.4.60.0070.01016.48
7.4.50.0060.00016.73
7.4.40.0000.01716.62
7.4.30.0100.00716.59
7.4.00.0040.00814.77
7.3.330.0000.00713.53
7.3.320.0000.00513.55
7.3.310.0040.00416.39
7.3.300.0050.00216.57
7.3.290.0100.01016.54
7.3.280.0080.00916.50
7.3.270.0180.00017.40
7.3.260.0060.01616.55
7.3.250.0090.00816.68
7.3.240.0150.00916.67
7.3.230.0090.00916.79
7.3.210.0070.01016.82
7.3.200.0000.01719.39
7.3.190.0160.00816.59
7.3.180.0070.01016.71
7.3.170.0120.00916.70
7.3.160.0110.00416.44
7.2.330.0150.00316.64
7.2.320.0090.00916.57
7.2.310.0100.00716.90
7.2.300.0090.00916.98
7.2.290.0130.00316.89
7.2.60.0080.00817.07
7.2.00.0090.00619.52
7.1.200.0070.00715.95
7.1.100.0030.00618.20
7.1.70.0100.00317.23
7.1.60.0110.01519.40
7.1.50.0090.01216.75
7.1.00.0000.08022.51
7.0.200.0000.00916.50
7.0.140.0000.07022.10
7.0.100.0270.03719.98
7.0.90.0100.04720.11
7.0.80.0230.03319.96
7.0.70.0400.04020.05
7.0.60.0100.05719.99
7.0.50.0330.04720.42
7.0.40.0030.04720.13
7.0.30.0030.06020.05
7.0.20.0030.04720.11
7.0.10.0070.04320.17
7.0.00.0130.03320.13
5.6.280.0070.07321.15
5.6.250.0030.04020.79
5.6.240.0070.04720.57
5.6.230.0000.04320.74
5.6.220.0070.07020.76
5.6.210.0030.04320.83
5.6.200.0070.04021.01
5.6.190.0030.05021.15
5.6.180.0030.07321.14
5.6.170.0070.03721.20
5.6.160.0100.04021.16
5.6.150.0030.04721.23
5.6.140.0000.05321.19
5.6.130.0100.04321.07
5.6.120.0130.03721.13
5.6.110.0130.03321.16
5.6.100.0030.07721.13
5.6.90.0070.06721.06
5.6.80.0170.06320.51
5.6.70.0070.08020.55
5.6.60.0070.06720.49
5.6.50.0130.06720.54
5.6.40.0130.06020.52
5.6.30.0100.08020.45
5.6.20.0200.06720.52
5.6.10.0030.08720.43
5.6.00.0030.08320.46
5.5.380.0100.03720.47
5.5.370.0100.07020.51
5.5.360.0100.03720.42
5.5.350.0000.05020.38
5.5.340.0030.04020.98
5.5.330.0070.05320.95
5.5.320.0030.07020.92
5.5.310.0070.04320.84
5.5.300.0170.03020.96
5.5.290.0100.03720.89
5.5.280.0130.03320.99
5.5.270.0100.04320.97
5.5.260.0070.04020.88
5.5.250.0000.04320.61
5.5.240.0130.07020.31
5.5.230.0030.08320.07
5.5.220.0030.08720.23
5.5.210.0100.06320.17
5.5.200.0030.08020.31
5.5.190.0100.04320.29
5.5.180.0130.06320.21
5.5.160.0100.07720.21
5.5.150.0030.08720.19
5.5.140.0070.08020.33
5.5.130.0130.07320.21
5.5.120.0070.04720.33
5.5.110.0100.07720.17
5.5.100.0130.07020.14
5.5.90.0100.07720.21
5.5.80.0170.07320.16
5.5.70.0070.07720.00
5.5.60.0130.07720.20
5.5.50.0100.07020.21
5.5.40.0100.04720.15
5.5.30.0100.07320.09
5.5.20.0070.08020.14
5.5.10.0130.08020.14
5.5.00.0000.08320.05
5.4.450.0070.05719.36
5.4.440.0100.03719.36
5.4.430.0030.05719.37
5.4.420.0130.03719.46
5.4.410.0130.07319.36
5.4.400.0100.07319.17
5.4.390.0170.07318.84
5.4.380.0070.04319.04
5.4.370.0030.06719.05
5.4.360.0000.05019.22
5.4.350.0100.07018.92
5.4.340.0070.07019.21
5.4.320.0070.08019.23
5.4.310.0230.06018.95
5.4.300.0070.06718.88
5.4.290.0000.08319.16
5.4.280.0130.07019.14
5.4.270.0200.06719.05
5.4.260.0100.07719.12
5.4.250.0130.06318.87
5.4.240.0170.06019.04
5.4.230.0070.07019.14
5.4.220.0170.07019.04
5.4.210.0070.08018.94
5.4.200.0200.06719.13
5.4.190.0100.07018.89
5.4.180.0070.05019.04
5.4.170.0070.05319.16
5.4.160.0100.06019.13
5.4.150.0070.04719.17
5.4.140.0070.06716.52
5.4.130.0030.04316.46
5.4.120.0130.06316.38
5.4.110.0230.05716.49
5.4.100.0200.06016.49
5.4.90.0170.06716.49
5.4.80.0070.06716.38
5.4.70.0130.06716.54
5.4.60.0130.06716.38
5.4.50.0100.04016.63
5.4.40.0030.07716.52
5.4.30.0070.07016.41
5.4.20.0100.07316.46
5.4.10.0070.05716.37
5.4.00.0100.03315.92

preferences:
45.44 ms | 401 KiB | 5 Q