Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

runkit_sandbox_output_handler(3) [php man page]

RUNKIT_SANDBOX_OUTPUT_HANDLER(3)					 1					  RUNKIT_SANDBOX_OUTPUT_HANDLER(3)

runkit_sandbox_output_handler - Specify a function to capture and/or process output from a runkit sandbox

SYNOPSIS
mixed runkit_sandbox_output_handler (object $sandbox, [mixed $callback]) DESCRIPTION
Ordinarily, anything output (such as with echo(3) or print(3)) will be output as though it were printed from the parent's scope. Using runkit_sandbox_output_handler(3) however, output generated by the sandbox (including errors), can be captured by a function outside of the sandbox. Note Sandbox support (required for runkit_lint(3), runkit_lint_file(3), and the Runkit_Sandbox class) is only available as of PHP 5.1.0 or specially patched versions of PHP 5.0, and requires that thread safety be enabled. See the README file included in the runkit package for more information. Note Deprecated As of runkit version 0.5, this function is deprecated and is scheduled to be removed from the package prior to a 1.0 release. The output handler for a given Runkit_Sandbox instance may be read/set using the array offset syntax shown on the Runkit_Sandbox class definition page. PARAMETERS
o $sandbox - Object instance of Runkit_Sandbox class on which to set output handling. o $callback - Name of a function which expects one parameter. Output generated by $sandbox will be passed to this callback. Anything returned by the callback will be displayed normally. If this parameter is not passed then output handling will not be changed. If a non- truth value is passed, output handling will be disabled and will revert to direct display. RETURN VALUES
Returns the name of the previously defined output handler callback, or FALSE if no handler was previously defined. EXAMPLES
Example #1 Feeding output to a variable <?php function capture_output($str) { $GLOBALS['sandbox_output'] .= $str; return ''; } $sandbox_output = ''; $php = new Runkit_Sandbox(); runkit_sandbox_output_handler($php, 'capture_output'); $php->echo("Hello "); $php->eval('var_dump("Excuse me");'); $php->die("I lost myself."); unset($php); echo "Sandbox Complete "; echo $sandbox_output; ?> The above example will output: Sandbox Complete Hello string(9) "Excuse me" I lost myself. PHP Documentation Group RUNKIT_SANDBOX_OUTPUT_HANDLER(3)

Check Out this Related Man Page

CALL_USER_FUNC_ARRAY(3) 						 1						   CALL_USER_FUNC_ARRAY(3)

call_user_func_array - Call a callback with an array of parameters

SYNOPSIS
mixed call_user_func_array (callable $callback, array $param_arr) DESCRIPTION
Calls the $callback given by the first parameter with the parameters in $param_arr. PARAMETERS
o $callback - The callable to be called. o $param_arr - The parameters to be passed to the callback, as an indexed array. RETURN VALUES
Returns the return value of the callback, or FALSE on error. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | The interpretation of object oriented keywords | | | like parent and self has changed. Previously, | | | calling them using the double colon syntax would | | | emit an E_STRICT warning because they were inter- | | | preted as static. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 call_user_func_array(3) example <?php function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2 "; } class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2 "; } } // Call the foobar() function with 2 arguments call_user_func_array("foobar", array("one", "two")); // Call the $foo->bar() method with 2 arguments $foo = new foo; call_user_func_array(array($foo, "bar"), array("three", "four")); ?> The above example will output something similar to: foobar got one and two foo::bar got three and four Example #2 call_user_func_array(3) using namespace name <?php namespace Foobar; class Foo { static public function test($name) { print "Hello {$name}! "; } } // As of PHP 5.3.0 call_user_func_array(__NAMESPACE__ .'Foo::test', array('Hannes')); // As of PHP 5.3.0 call_user_func_array(array(__NAMESPACE__ .'Foo', 'test'), array('Philip')); ?> The above example will output something similar to: Hello Hannes! Hello Philip! Example #3 Using lambda function <?php $func = function($arg1, $arg2) { return $arg1 * $arg2; }; var_dump(call_user_func_array($func, array(2, 4))); /* As of PHP 5.3.0 */ ?> The above example will output: int(8) NOTES
Note Before PHP 5.4, referenced variables in $param_arr are passed to the function by reference, regardless of whether the function expects the respective parameter to be passed by reference. This form of call-time pass by reference does not emit a deprecation notice, but it is nonetheless deprecated, and has been removed in PHP 5.4. Furthermore, this does not apply to internal functions, for which the function signature is honored. Passing by value when the function expects a parameter by reference results in a warn- ing and having call_user_func(3) return FALSE (there is, however, an exception for passed values with reference count = 1, such as in literals, as these can be turned into references without ill effects -- but also without writes to that value having any effect --; do not rely in this behavior, though, as the reference count is an implementation detail and the soundness of this behavior is questionable). Note Callbacks registered with functions such as call_user_func(3) and call_user_func_array(3) will not be called if there is an uncaught exception thrown in a previous callback. SEE ALSO
call_user_func(3), information about the callback type, ReflectionFunction::invokeArgs, ReflectionMethod::invokeArgs. PHP Documentation Group CALL_USER_FUNC_ARRAY(3)
Man Page