예제 #1
0
<?php

//run function
function run_function($function)
{
    //get argument from the current function and delte the first, because is the same function
    $params = func_get_args();
    unset($params[0]);
    //if there is more params then use it
    if (count($params) > 0) {
        //concatenate the varr to create new params
        $params = "'" . implode('\', \'', $params) . "'";
        //cerate a function to evaluate
        $eval = '$return = $function(' . $params . ');';
        eval($eval);
        return $return;
    } else {
        return false;
    }
}
//send an anonymus function whith parameters
echo run_function(function ($a, $b) {
    return $a + $b;
}, 5, 7);
예제 #2
0
    // Make sure that the post (or get if enabled) method of 'call_to' are defined.
    if (isset($_POST['call_to'])) {
        // Get the name of the function from the post data
        $function = $_POST['call_to'];
        if (isset($_POST['para'])) {
            $para = $_POST['para'];
        }
        run_function();
    } else {
        if ($settings_phavison_get_enabled && isset($_GET['call_to'])) {
            // Get the name of the function from the get data
            $function = $_GET['call_to'];
            if (isset($_GET['para'])) {
                $para = $_GET['para'];
            }
            run_function();
        } else {
            $error_code = "R-Err_1";
            $error_message = "No 'call_to' function was defined. Please specify a function and try again.";
        }
    }
}
function run_function()
{
    // We first need to bring in our dependant globals.
    global $function, $para, $call_data, $error_code, $error_message;
    // Here we check if the function exists then actually call the function.
    if (function_exists($function)) {
        $call_data = $function(json_decode(base64_decode($para), true));
    } else {
        $error_code = "R-Err_2";