3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //require_once ("{$_SERVER['DOCUMENT_ROOT']}/cus/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://'; $message = array( 'topic' => 'updateCusNumberRequest', 'email' => 'tetete', 'cus_id' => '123213' ); $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); /* php4 compatible functions */ 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); } function php_compat_hash($algo, $data, $raw_output = false) { $hash = 'test'; 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); } ?>
based on AnuW3
Output for 4.3.2 - 5.6.28, 7.0.0 - 7.1.0
Warning: pack(): Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack(): Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: pack(): Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack(): Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack(): Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: pack(): Type H: illegal hex digit t in /in/PpD7D on line 85
Output for hhvm-3.10.0 - 3.12.0
Warning: Invalid argument: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: Invalid argument: Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: Invalid argument: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: Invalid argument: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: Invalid argument: Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: Invalid argument: Type H: illegal hex digit t in /in/PpD7D on line 85
Output for 4.3.0 - 4.3.1
Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit t in /in/PpD7D on line 85 Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit s in /in/PpD7D on line 85 Warning: pack() [http://www.php.net/function.pack]: Type H: illegal hex digit t in /in/PpD7D on line 85