Passing a function & arguments to a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to pass a function as an argument to another function, and
then run the first function from within the second function.

Example:

    function function0($arg0, $arg1, $arg2) {

        function2();

    }

    function function1($arg3, $arg4, $arg5) {

        function3();
        do_function($arg5);
        function4();

    }


    function1(5, 100, function0($arg0, $arg1, $arg2));
    



In the above example, I am running function1(), which includes
function0 as an argument.

I am trying to pass "function0($arg0, $arg1, $arg2)" as an argument to
function1, which will then execute the passed function, including its
passed arguments.

I have had mild success by splitting "function0($arg0, $arg1, $arg2)"
into 2 parts of "function0" and "$arg0, $arg1, $arg2", and then
passing both parts as an argument, such as $arg5 & $arg6, and then
doing this:

    function function1($arg3, $arg4, $arg5) {

            $args_array = explode(", ",$arg6);
            $arg5($args_array[0],$args_array[1],$args_array[2]);

        }
    


However, this causes all of my arguments in the array to be evaluated
as strings and not resources, which they may be.

Also, I don't really like this method, and would prefer a much
"cleaner" way of doing things.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux