3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Qiniu { private $bucket; private $ak; private $sk; public function __constructor($bucket, $ak, $sk) { $this->bucket = $bucket; $this->ak = $ak; $this->sk = $sk; } public function token($filename) { $encodedPutPolicy = $this->base64_encode(json_encode(array( "scope" => $this->bucket.":$filename", "deadline" => time()+3600, "saveKey" => $filename ))); $encodeSign = $this->base64_encode(hash_hmac("sha1", $encodedPutPolicy, $this->sk, true)); return $this->ak.":$encodeSign:$encodedPutPolicy"; } public function base64_encode($text) { return str_replace( array('+', '/'), array('-', '_'), base64_encode($text) ); } } $q = new Qiniu("pmblog", "OPB7jSpoHc4IjnGiRfPo2O0kVtpGMQ9NJ0jmaHFW", "pAkkX6dnBQPVpuN11x4cPTt8NB-nYQXHI7jd4e4i"); echo $q->token("1409623700159.jpg");
Output for 5.2.0 - 7.3.0beta1
:Bs0M5YoQBCV8-vB7EeRQRjR-0UQ=:eyJzY29wZSI6IjoxNDA5NjIzNzAwMTU5LmpwZyIsImRlYWRsaW5lIjoxNDA5NjI3NDk3LCJzYXZlS2V5IjoiMTQwOTYyMzcwMDE1OS5qcGcifQ==
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/QQVHC on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QQVHC on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QQVHC on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/QQVHC on line 4
Process exited with code 255.