Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Tip : create a function dynamically using create_function

Discussion in 'Programming' started by dman_2007, Apr 7, 2008.

  1. dman_2007

    dman_2007 Guest

    You can create a function dynamically in php by using create_function function. This is especiallyuseful for creating anonymous callback functions. First parameter to the create_function function is a string specifying the function arguments and second parameter is a string specifying function body. For example :

     $dynamic_func = create_function('$arg1, $arg2', 'return pow($arg1, $arg2);');
     echo $dynamic_func(2,6); 

Featured Resources (View All)

Share This Page