Jump to content

[SOLVED] variable function name??


severndigital

Recommended Posts

this might be impossible, but i had an idea and can't seem to find if it is possible.

 

I have a quite a few of functions that I need to call based on the content of a variable.

 

all the functions are basically named the same except for the content of the variable.

 

can I load the variable as part of the function name??

 

here is some code that might help to explain it better.

 


$variable = $_POST['renderIntent']; //this can be a bunch of different things we'll say HTML for this example.

render_$variable_info(); // which would translate to render_HTML_info();

 

i know the easiest way would be to make an if else and go through all the functions. but there are more than a few possibles. Unfortunately this is how the code is now, and I'm trying to make the best of crappy situation.

 

any help would be great.

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/178267-solved-variable-function-name/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.