Jump to content

Is This Possible?


glenelkins

Recommended Posts

Hi

 

Im writing an app and I would like to create a class with a name that is specified either in a database or a variable. Is this possible?

 

for example, can something like this be done?

 


$class_name = "test";

class $class_name {

}

 

This code doesnt work, but I was wondering if there was a way to do this?

 

Also, Iv seen many of times variables set like this in a string  echo "Hello my name is {$name}" ... what exactly are the {} for? they are not needed so why are they there?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/127831-is-this-possible/
Share on other sites

No you have what im saying wrong.

 

I know i can call a function like this

 

function test(){

}

 

$function = "test";

 

$function();

 

 

What im saying is can a function be "created" the same way? Like so:

 

$function_name = "test";

 

// Create the function

$function_name(){

 

}

Link to comment
https://forums.phpfreaks.com/topic/127831-is-this-possible/#findComment-661810
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.