php - How to open a file using Runkit_Sandbox -


i use following code open file 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');  ?> 

i create data.txt file in '/var/www/html/test/' directory appropriate permission. however, still error:

warning: runkit_sandbox::__call(): unable translate resource, or object variable current context. in /var/www/html/test/write1.php on line 10 

what missing here?

fopen() returns resource. resources , objects cannot exchanged between interpreters. basicly open file inside sandbox, , ask return file handle sandbox current context. not possible.

you can use eval():

$sandbox->eval('   $f = fopen("/var/www/html/test/data.txt", "r");   // ... rest of code '); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -