我使用以下代码使用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');
?>我已经使用适当的权限在'/var/www/html/test/‘目录中创建了data.txt文件。但是,我仍然会看到以下错误:
Warning: Runkit_Sandbox::__call(): Unable to translate resource, or object variable to current context. in /var/www/html/test/write1.php on line 10我在这里错过了什么?
发布于 2014-06-27 15:55:35
fopen()返回一个资源。资源和对象不能在解释器之间交换。基本做法是在沙箱内打开文件,并要求将文件句柄从沙箱返回到当前上下文中。这是不可能的
您可以使用eval():
$sandbox->eval('
$f = fopen("/var/www/html/test/data.txt", "r");
// ... rest of the code
');https://stackoverflow.com/questions/24454904
复制相似问题