Forum Moderators: coopster

Message Too Old, No Replies

create a new function. without knowing the name

possible?

         

londrum

5:30 pm on Aug 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hello. ive been reading up on variable function names, but i can't quite get it to do what i want it to do,

i know that this works okay...

$func = 'blah';

$func();    // This calls the function blah()

but that only calls the blah function if it already exists. but what happens if you want to create that new blah function right now?

this is what i'd like to do...

$func = 'blah';

$func() {

// function code

;}

$func();    // This calls the function blah()

what i'm trying to do is create one function that will cover hundreds of different query strings. the only part of the function that changes is the text (taken from the query string), and the name of the function itself -- which needs to be the same as the query string.

the only alternative that i can see is to write out hundreds of different functions to cover all the strings -- and that will do my head in!

andrewsmd

10:01 pm on Aug 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



check out the create_function() method. If you have the code already you can just create a temp function in the loop that retrieves your data. Just and FYI creating functions like that can get a bit tricky. If you can, try to create a static function that takes in the variables.