我使用以下代码通过Runkit_Sandbox打开文件:
<?php
$options = array(
'open_basedir'=>'/var/www/html/test/',
'allow_url_fopen'=>'true',
);
$sandbox = new Runkit_Sandbox($options);
$sandbox->ini_set('html_errors',true);
$sandbox->fopen('/var/www/html/test/data.txt', 'r');
?>
我已经data.txt
在具有适当权限的'/ var / www / html / test /'目录中创建了文件。但是,我仍然收到此错误:
Warning: Runkit_Sandbox::__call(): Unable to translate resource, or object variable to current context. in /var/www/html/test/write1.php on line 10
我在这里想念什么?
fopen()
返回资源。资源和对象不能在解释器之间交换。您基本上要做的是打开沙箱中的文件,并要求将文件句柄从沙箱返回到当前上下文中。这是不可能的。
您可以使用eval():
$sandbox->eval('
$f = fopen("/var/www/html/test/data.txt", "r");
// ... rest of the code
');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句