NYCPHP Meetup

NYPHP.org

[nycphp-talk] Dynamically write functions

Frank Wong frank_wong2 at informationideas.com
Thu May 12 17:17:50 EDT 2005


I am wondering if there is a way to write functions dynamically.  This 
is what I am trying to do.

Currently, I have the following:
-------------------------------------------------
function foo1 () {
    global bar1, bar2;

    // code
}
function foo2 () {
    global bar1, bar2;

    // code
}
-------------------------------------------------


I want to do something like the following:
-------------------------------------------------
function write_globals() {
    $output = 'global bar1, bar2;'
    return $output;
}
function foo1 () {
    write_globals();

    // code
}
functioin foo2 () {
    write_globals();

    // code
}
-------------------------------------------------

Obviously, the above code does not work as it is written.  But I was 
wondering if anyone knows a way to make that happen.  TIA


________________________
Frank Wong




More information about the talk mailing list