PHP7引入了一个新功能:<?php
$data = 'zzzzzzzzzzzzzzzzzzzzzzzzzzz';
$context = deflate_init(ZLIB_ENCODING_GZIP);
var_dump($context);
$fp = fopen('php://memory', 'wb+', false, $context);
fputs($fp, $data);
rewind($fp);
echo bin2hex(stream_get_contents($fp)) . "\n";
。这是关于它的文档:
http://php.net/manual/en/function.deflate-init.php
我试图使用它,但我无法这样做。我的代码:
resource(4) of type (zlib.deflate)
Warning: fopen(): supplied resource is not a valid Stream-Context resource in /path/to/file.php on line 6
运行它会得到以下输出:
deflate_init
根据PHP文档,当deflate_init
按原样调用时会返回false,并且应该从该函数抛出E_WARNING错误。但这些事情都没有发生,所以似乎var pose = {};
var eye = {};
var left = {};
left.pitchPos = 37;
left.yawPos = 47;
exports.init = function () {
eye.left = left;
pose.eye = eye;
return this;
};
exports.eye = function (e) {
if(typeof(e) !== "undefined"){
pose.eye = e;
}
return pose;
};
exports.pose = pose;
调用至少是有效的。
有什么想法吗?