3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.26, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.6
:Bs0M5YoQBCV8-vB7EeRQRjR-0UQ=:eyJzY29wZSI6IjoxNDA5NjIzNzAwMTU5LmpwZyIsImRlYWRsaW5lIjoxNDA5NjI3NDk3LCJzYXZlS2V5IjoiMTQwOTYyMzcwMDE1OS5qcGcifQ==
Output for 5.0.0 - 5.0.5, 5.1.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.3.11, 4.4.0 - 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.

preferences:
163.47 ms | 401 KiB | 220 Q