Re: How to pass a function to a function?, and how to pass the variables of the function?




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


.



Relevant Pages

  • Re: pass by reference
    ... But if you do your research with textbooks on programming ... languages, ... start an argument over the proper meaning of pass by reference. ... Chris Smith ...
    (comp.lang.java.programmer)
  • Re: A++ == B: Always True?
    ... Chris> I think you missed the point of Michael's response. ... Chris> doesn't have at least the basic ASCII characters (even ... If you can't generally trust the compiler to implement the Java ... about a fundamental difference between the languages that he was ...
    (comp.lang.java.programmer)
  • Re: low sugar - spotty vision
    ... dozen computer languages. ... at least Chris has a degree in what he does. ... jumping in and looking stupid, you must have cut and pasted that from ... BTW, genius, "stupider" is not a word. ...
    (alt.support.diabetes)
  • Re: pinpoint desk location
    ... for the book are provided in two languages, I think Java and C++. ... been able to find the book for a few years, but there is a web site in which ... Prev by Date: ...
    (microsoft.public.vb.winapi)
  • Identity crisis
    ... But, when I switch to the other identity, I show zero names in that contact ... although I am sharing an ... Chris ... Prev by Date: ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)

Loading