Jump to content

Recommended Posts

Use $mvar();

 

However why would want to store function names in a variable? Make sure these variables are not set by the user otherwise you could cause security exploits in your code.

Don't know why he need it Oo

Can you please explain me about $mvar()? google and php.net gives me nothing =p

Umm, $myvar is your actual variable, the () is so PHP calls the function

 

eg

$var = 'hello';

function hello() { return 'hello world'; };

echo $var();

 

Hey wow I didn't know you could do that; learn somethin' new every day :) I was just gonna suggest eval()

In a primitive example it doesn't show much use.  the only realistic example is in a need to have a function be executed based off a user's input but even then a switch can be the same or better assuming a reasonable number of choices.

 

 

Why use eval??

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.