Feb 8 2008

Dynamic Function Calling in PHP

Dynamic Function Calling in PHP Dynamic Function Calling in PHP

Why php is more flexible ? See this function example:

Class Record

{

public function getMessage()

{

return "Hello world";

}
}

//You can call this function like this:

$function = "getMessage";

$R = new Record;

call_user_func( array($R, $function   )  );

If you want to pass some argument , you can use rest of the parameters of call-user_function;

eg: call_user_func( array($R, $function ) , $param, $param2);

For more info: http://www.php.net/call_user_func

1 Comments on this post

Trackbacks

  1. Tom said:

    You can also do
    $R->$function($param, $param2);

    September 4th, 2008 at 8:47 pm

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sponsors

    Advt on sajithmr.com
    Advt on sajithmr.com
    Advt on sajithmr.com
    Itslife Online

Recent Comments

  • Binny V A: Thanks for the post - love the picture ;-)
  • TheAnand: A lot of people are seeing errors with google video chat….is there any other software which has to be...
  • Alex: Wow, interresting analysis you have done! I’m trying to run GoogleVoiceAndVideoSetup on linux, using...
  • Mella Fitriansyah: Nice plugin, I will try to add this plugin in my blog…
  • Mella Fitriansyah: Nice Info, Sir i will reading your another post success for you

Recent Readers

JOIN MY COMMUNITY!

Recent Posts