• 11th September 2006 -By Vinu Thomas

    Another did you know in PHP.

    < ?
    function test() {
    echo "This function can be called dynamically!";
    }
    $function_name = "test";
    $function_name();
    ?>

    What is the output of the code show above? If you guessed that the output is “This function can be called dynamically!”, you may be a PHP guru. :)

    The code shows you how to dynamically call the function test without actually calling test(). This method of calling a function could be useful in complex applications where you have to call on a function dynamically from you code.

    Here’s a tutorial which shows you how to use :

    • Dynamic Vairables
    • Dynamic functions and objects
    • Dynamic static properties and methods

    When you’re trying to build more complex classes/applications, the need for doing things dynamically often arises. I figured I’d compile a list of ways to do dynamic PHP for those starting out with PHP. Please note that the list was elaborated with PHP 5 in mind.

    Link: epiphantastic » Blog Archive » Dynamic PHP

  • Leave a Reply