3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once (dirname(__FILE__) . "/sha256.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://'; $email = ''; $cus_id = ''; if ($argc >= 2) { $email = $argv[1]; $cus_id = $argv[2]; } $message = array( 'topic' => 'updateCusNumberRequest', 'email' => $email, 'cus_id' => $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 " . $output; } 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/1qd0Usl 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 = php_compat_hash($algo, $key, true); } else { $key = str_pad($key, $blocksize, "\x00"); } $ipad ^= $key; $opad ^= $key; return php_compat_hash($algo, $opad . php_compat_hash($algo, $ipad . $data, true), $raw_output); } //http://bit.ly/1nIYD2h function php_compat_hash($algo, $data, $raw_output = false) { $hash = hash('sha256', $data); if ($raw_output) { return pack('H*', $hash); } else { echo "returnhash"; return $hash; } } //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); } if (!function_exists('hash')) { function hash($algo, $data) { if (empty($algo) || !is_string($algo) || !is_string($data)) { return false; } if (function_exists($algo)) { return $algo($data); } } } ?>

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.0060.01216.63
8.3.50.0090.01322.72
8.3.40.0090.00618.80
8.3.30.0090.00619.18
8.3.20.0040.00420.46
8.3.10.0030.00523.65
8.3.00.0040.00419.38
8.2.180.0130.00616.50
8.2.170.0060.01622.96
8.2.160.0070.00720.68
8.2.150.0090.00024.18
8.2.140.0060.00324.66
8.2.130.0060.01226.16
8.2.120.0040.00420.97
8.2.110.0030.00722.10
8.2.100.0090.00318.09
8.2.90.0030.00919.22
8.2.80.0090.00017.97
8.2.70.0060.00317.62
8.2.60.0000.00818.16
8.2.50.0090.00018.07
8.2.40.0040.00419.75
8.2.30.0000.00818.09
8.2.20.0060.00317.98
8.2.10.0000.00918.11
8.2.00.0050.00317.97
8.1.280.0060.00925.92
8.1.270.0040.00423.66
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0030.00623.74
8.1.230.0080.00419.18
8.1.220.0000.00817.74
8.1.210.0080.00018.77
8.1.200.0100.00717.11
8.1.190.0000.00917.48
8.1.180.0030.00618.10
8.1.170.0040.00418.70
8.1.160.0020.00522.10
8.1.150.0000.00719.02
8.1.140.0040.00417.55
8.1.130.0030.00317.88
8.1.120.0060.00317.55
8.1.110.0050.00317.35
8.1.100.0000.01017.41
8.1.90.0000.00717.50
8.1.80.0000.00817.48
8.1.70.0000.00817.39
8.1.60.0060.00317.68
8.1.50.0000.00817.61
8.1.40.0000.00817.53
8.1.30.0030.00517.72
8.1.20.0050.00317.79
8.1.10.0080.00017.63
8.1.00.0030.00917.64
8.0.300.0000.00818.77
8.0.290.0040.00417.00
8.0.280.0070.00018.55
8.0.270.0000.00717.37
8.0.260.0000.00717.35
8.0.250.0030.00317.20
8.0.240.0070.00017.20
8.0.230.0000.00717.20
8.0.220.0070.00017.03
8.0.210.0030.00317.16
8.0.200.0070.00017.09
8.0.190.0050.00217.16
8.0.180.0040.00417.14
8.0.170.0080.00017.02
8.0.160.0040.00417.10
8.0.150.0000.00817.02
8.0.140.0040.00417.02
8.0.130.0000.00713.63
8.0.120.0100.00015.35
8.0.110.0100.00015.34
8.0.100.0060.00415.27
8.0.90.0030.00415.30
8.0.80.0070.00515.29
8.0.70.0070.00415.26
8.0.60.0020.00815.34
8.0.50.0060.00415.31
8.0.30.0100.00615.89
8.0.20.0150.00716.13
8.0.10.0040.00515.27
8.0.00.0020.01215.78
7.4.330.0060.00015.16
7.4.320.0000.00716.61
7.4.300.0000.00616.63
7.4.290.0030.00316.73
7.4.280.0040.00416.52
7.4.270.0000.00816.74
7.4.260.0000.00816.71
7.4.250.0060.00215.05
7.4.240.0060.00415.59
7.4.230.0050.00515.02
7.4.220.0020.01314.97
7.4.210.0060.00715.03
7.4.200.0060.00415.05
7.4.190.0080.00413.55
7.4.180.0050.00213.46
7.4.160.0070.00815.12
7.4.150.0080.00615.34
7.4.140.0080.00616.37
7.4.130.0110.00615.46
7.4.120.0070.00815.52
7.4.110.0080.00414.92
7.4.100.0080.00714.93
7.4.90.0090.00915.09
7.4.80.0080.00716.34
7.4.70.0040.00914.99
7.4.60.0060.00815.06
7.4.50.0040.00414.71
7.4.40.0140.00214.85
7.4.30.0080.00514.90
7.4.20.0040.00413.20
7.4.10.0100.00013.25
7.4.00.0030.01214.29
7.3.330.0050.00213.47
7.3.320.0060.00013.55
7.3.310.0050.00514.90
7.3.300.0050.00314.88
7.3.290.0120.00315.01
7.3.280.0070.00915.77
7.3.270.0080.00915.37
7.3.260.0060.01315.02
7.3.250.0100.00515.47
7.3.240.0100.00514.86
7.3.230.0080.00815.03
7.3.220.0030.00613.36
7.3.210.0060.00714.96
7.3.200.0120.00316.37
7.3.190.0050.00715.03
7.3.180.0080.00515.11
7.3.170.0100.00314.93
7.3.160.0060.00614.93
7.3.150.0070.00013.42
7.3.140.0070.00013.47
7.3.130.0030.00313.37
7.3.120.0080.00314.13
7.3.110.0050.00614.13
7.3.100.0050.00614.07
7.3.90.0030.00714.26
7.3.80.0040.00514.28
7.3.70.0050.00514.12
7.3.60.0030.00614.24
7.3.50.0050.00314.06
7.3.40.0080.00214.07
7.3.30.0030.00714.18
7.3.20.0070.00215.85
7.3.10.0050.00816.10
7.3.00.0050.00815.93
7.2.340.0000.01213.40
7.2.330.0090.00715.11
7.2.320.0100.00714.99
7.2.310.0080.00814.93
7.2.300.0110.00515.00
7.2.290.0110.00514.94
7.2.280.0130.00013.41
7.2.270.0120.00013.37
7.2.260.0060.00613.40
7.2.250.0100.00714.19
7.2.240.0080.00814.29
7.2.230.0080.00614.28
7.2.220.0030.00914.16
7.2.210.0080.00314.09
7.2.200.0090.00514.39
7.2.190.0090.00414.29
7.2.180.0090.00514.32
7.2.170.0050.00814.38
7.2.160.0060.00613.29
7.2.150.0130.00015.33
7.2.140.0080.00415.25
7.2.130.0110.00715.87
7.2.120.0030.01116.05
7.2.110.0110.00316.10
7.2.100.0090.00215.95
7.2.90.0050.00916.07
7.2.80.0050.00916.01
7.2.70.0070.00615.88
7.2.60.0060.00515.99
7.2.50.0070.00716.03
7.2.40.0070.00616.05
7.2.30.0030.01116.14
7.2.20.0070.00816.18
7.2.10.0080.00716.06
7.2.00.0060.00817.11
7.1.330.0060.00815.01
7.1.320.0040.01014.90
7.1.310.0070.00314.91
7.1.300.0040.00815.02
7.1.290.0060.00415.06
7.1.280.0080.00514.87
7.1.270.0110.00315.04
7.1.260.0100.00414.94
7.1.250.0120.00514.78
7.1.240.0040.00814.00
7.1.230.0120.00014.28
7.1.220.0060.00614.16
7.1.210.0090.00314.31
7.1.200.0090.00414.14
7.1.190.0100.00214.25
7.1.180.0040.00814.11
7.1.170.0080.00414.08
7.1.160.0090.00314.24
7.1.150.0120.00014.05
7.1.140.0060.00614.17
7.1.130.0060.00614.04
7.1.120.0040.00814.21
7.1.110.0090.00214.21
7.1.100.0080.00516.03
7.1.90.0040.00914.22
7.1.80.0120.00014.20
7.1.70.0100.00015.43
7.1.60.0120.00316.86
7.1.50.0150.00724.53
7.1.40.0120.00014.30
7.1.30.0080.00414.32
7.1.20.0100.00314.05
7.1.10.0100.00314.19
7.1.00.0130.03318.17
7.0.330.0090.00314.18
7.0.320.0120.00014.16
7.0.310.0100.00214.18
7.0.300.0090.00313.96
7.0.290.0080.00414.18
7.0.280.0060.00614.09
7.0.270.0080.00514.26
7.0.260.0110.00014.20
7.0.250.0060.00614.25
7.0.240.0080.00414.16
7.0.230.0090.00314.26
7.0.220.0100.00214.20
7.0.210.0060.00614.09
7.0.200.0140.00914.44
7.0.190.0120.00014.18
7.0.180.0090.00314.18
7.0.170.0130.00014.30
7.0.160.0090.00313.95
7.0.150.0000.01214.18
7.0.140.0080.03517.99
7.0.130.0080.00414.03
7.0.120.0060.00614.17
7.0.110.0070.00513.95
7.0.100.0100.01716.99
7.0.90.0060.01817.08
7.0.80.0080.02016.95
7.0.70.0050.02317.06
7.0.60.0100.01817.05
7.0.50.0090.02017.14
7.0.40.0040.02617.06
7.0.30.0040.02417.18
7.0.20.0040.02517.10
7.0.10.0050.02416.94
7.0.00.0100.02017.11
5.6.400.0080.00312.65
5.6.390.0060.00612.40
5.6.380.0080.00312.82
5.6.370.0120.00012.75
5.6.360.0080.00412.74
5.6.350.0080.00412.82
5.6.340.0110.00012.66
5.6.330.0040.00812.71
5.6.320.0090.00212.75
5.6.310.0090.00312.80
5.6.300.0110.00012.63
5.6.290.0060.00612.65
5.6.280.0060.03816.95
5.6.270.0050.00512.61
5.6.260.0080.00312.66
5.6.250.0060.02316.61
5.6.240.0110.01816.60
5.6.230.0060.02116.74
5.6.220.0060.02116.65
5.6.210.0070.02216.78
5.6.200.0040.02516.81
5.6.190.0080.01816.96
5.6.180.0040.02616.93
5.6.170.0080.02116.90
5.6.160.0110.01816.90
5.6.150.0060.02316.87
5.6.140.0060.02416.94
5.6.130.0040.02516.92
5.6.120.0070.02216.89
5.6.110.0050.03216.90
5.6.100.0080.04616.74
5.6.90.0070.03516.94
5.6.80.0060.02216.63
5.6.70.0100.03616.54
5.6.60.0070.02016.60
5.6.50.0100.04016.51
5.6.40.0060.02116.50
5.6.30.0120.03016.60
5.6.20.0120.03716.66
5.6.10.0100.03816.41
5.6.00.0130.03416.62
5.5.380.0060.02216.68
5.5.370.0080.02216.52
5.5.360.0090.02216.48
5.5.350.0080.02116.42
5.5.340.0080.02116.56
5.5.330.0020.02516.77
5.5.320.0040.02316.68
5.5.310.0090.01816.61
5.5.300.0030.02416.82
5.5.290.0040.02316.77
5.5.280.0110.02216.68
5.5.270.0080.02116.72
5.5.260.0110.02016.67
5.5.250.0030.04316.63
5.5.240.0090.03916.37
5.5.230.0140.03016.38
5.5.220.0110.02816.35
5.5.210.0060.02616.46
5.5.200.0070.04016.43
5.5.190.0080.02716.31
5.5.180.0080.04516.37
5.5.170.0070.00412.68
5.5.160.0090.03816.34
5.5.150.0100.04216.47
5.5.140.0090.04016.23
5.5.130.0100.03616.29
5.5.120.0070.04216.19
5.5.110.0050.04616.34
5.5.100.0080.03916.42
5.5.90.0080.04316.26
5.5.80.0070.02516.28
5.5.70.0110.04016.37
5.5.60.0080.04216.34
5.5.50.0060.03916.34
5.5.40.0050.04216.37
5.5.30.0070.03816.34
5.5.20.0080.04016.47
5.5.10.0090.04016.38
5.5.00.0070.04016.22
5.4.450.0040.02016.05
5.4.440.0070.01615.93
5.4.430.0040.02515.96
5.4.420.0070.02015.98
5.4.410.0080.02615.80
5.4.400.0050.02715.87
5.4.390.0110.01415.81
5.4.380.0080.01615.83
5.4.370.0060.02015.88
5.4.360.0100.03915.84
5.4.350.0080.04115.69
5.4.340.0050.02215.90
5.4.330.0090.00212.71
5.4.320.0110.03515.89
5.4.310.0070.02815.78
5.4.300.0060.03515.83
5.4.290.0090.03815.80
5.4.280.0060.02615.78
5.4.270.0090.03815.93
5.4.260.0090.03515.74
5.4.250.0080.02815.80
5.4.240.0090.02215.73
5.4.230.0090.03615.72
5.4.220.0040.03915.82
5.4.210.0050.03715.66
5.4.200.0060.02215.70
5.4.190.0110.03815.67
5.4.180.0090.02815.66
5.4.170.0100.02015.92
5.4.160.0060.02615.68
5.4.150.0070.04015.72
5.4.140.0060.03514.40
5.4.130.0090.03314.52
5.4.120.0090.02014.45
5.4.110.0070.01814.62
5.4.100.0080.01814.63
5.4.90.0080.03214.35
5.4.80.0090.02014.57
5.4.70.0070.03514.59
5.4.60.0110.02814.43
5.4.50.0050.02014.43
5.4.40.0050.02214.52
5.4.30.0090.02314.40
5.4.20.0090.02014.62
5.4.10.0120.03714.56
5.4.00.0060.03914.10

preferences:
55.26 ms | 401 KiB | 5 Q