Torsten Roehr wrote:

"Bob Lockie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

I want to pass a function as a parameter and execute it in another

function.

A callback. :-)

For example:

function a() {
    echo "a";
}


function b( $func ) { func(); echo "b"; }


The output of "b( a )" will be "ab".


Take a look at call_user_func():
http://de3.php.net/manual/en/function.call-user-func.php

You have to pass the name of the function instead of the function itself:

function a() {
     echo "a";
}

function b($func) {
     call_user_func($func);
     echo "b";
}

b('a');

Regards, Torsten

You can also do it this way:

function b($func) {
  $func();
  echo 'b';
}

--
paperCrane <Justin Patrin>

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



Reply via email to