Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : runkit Functions : Runkit_Sandbox

Runkit_Sandbox

Runkit Sandbox Class -- PHP Virtual Machine ()
void Runkit_Sandbox::__construct ( [array options] )

Example 2077. Instantiating a restricted sandbox

<?php
$options
= array(
 
'safe_mode'=>true,
 
'open_basedir'=>'/var/www/users/jdoe/',
 
'allow_url_fopen'=>'false',
 
'disable_functions'=>'exec,shell_exec,passthru,system',
 
'disable_classes'=>'myAppClass');
$sandbox = new Runkit_Sandbox($options);
/* Non-protected ini settings may set normally */
$sandbox->ini_set('html_errors',true);
?>

Example 2078. Working with variables in a sandbox

<?php
$sandbox
= new Runkit_Sandbox();

$sandbox->foo = 'bar';
$sandbox->eval('echo "$foo\n"; $bar = $foo . "baz";');
echo
"{$sandbox->bar}\n";
if (isset(
$sandbox->foo)) unset($sandbox->foo);
$sandbox->eval('var_dump(isset($foo));');
?>

Example 2079. Calling sandbox functions

<?php
$sandbox
= new Runkit_Sandbox();

echo
$sandbox->str_replace('a','f','abc');
?>

Example 2080. Passing arguments to sandbox functions

<?php
$sandbox
= new Runkit_Sandbox();

$foo = 'bar';
$sandbox->foo = 'baz';
echo
$sandbox->str_replace('a',$foo,'a');
echo
$sandbox->str_replace('a',$sandbox->foo,'a');
?>

Change Language


Follow Navioo On Twitter
Runkit_Sandbox
Runkit_Sandbox_Parent
runkit_class_adopt
runkit_class_emancipate
runkit_constant_add
runkit_constant_redefine
runkit_constant_remove
runkit_function_add
runkit_function_copy
runkit_function_redefine
runkit_function_remove
runkit_function_rename
runkit_import
runkit_lint_file
runkit_lint
runkit_method_add
runkit_method_copy
runkit_method_redefine
runkit_method_remove
runkit_method_rename
runkit_return_value_used
runkit_sandbox_output_handler
runkit_superglobals
eXTReMe Tracker