Re: How to pass a function to a function?, and how to pass the variables of the function?
- From: "Fabian Hore" <fabianhore@xxxxxxxxx>
- Date: Sat, 24 Sep 2005 01:06:23 +0100
What Chris points you to is indeed the right place to look, but the fact
that you write $function_to_execute()
suggests you may be used to languages such as Javascript, or Actionscript
where everything is an object.
This fundamental difference in PHP may catch you out another time.
*A Function is not an object*. As you'll see from the usage of
call_user_func().
"Chris Hope" <blackhole@xxxxxxxxxxxxxxxxxxx> wrote in message
news:dh0aro$qhl$1@xxxxxxxxxxxxxxxxxx
> _andrea.l wrote:
>
>> I'd like to write a function like:
>>
>> function f(){ ... bla ...}
>> f_example(f);
>>
>> function f_example($function_to_execute)
>> {...bla... $function_to_execute() ...bla....}
>>
>> AND how to pass the variable of the function :
>>
>> function f_example($function_to_execute($var1,$var2))
>> {...bla... $function_to_execute() ...bla....}
>>
>> Thank you in advance for the time you'll spend for me,
>> Andrea.
>
> This should get you going in the right direction:
> http://www.php.net/manual/en/function.call-user-func-array.php
>
> --
> Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
.
- References:
- Prev by Date: Re: Decrementing a number...
- Next by Date: Re: How to pass a function to a function?, and how to pass the variables of the function?
- Previous by thread: Re: How to pass a function to a function?, and how to pass the variables of the function?
- Next by thread: Re: How to pass a function to a function?, and how to pass the variables of the function?
- Index(es):
Relevant Pages
|
Loading