php - Use contents of string variable to call function -


i have following piece of code

copy($source, $target); 

i use

move_uploaded_file($source, $target); 

to prevent code reuse, want pass copy , move_uploaded_file in via variable.

if variable $var = "copy";, putting $var($source, $target);, doesn't seem work.

are there special characters must surround $var?

thanks.

the correct syntax $var (variable functions), code should work.

but please don't that, write code in straightforward , readable manner. there are legitimate use cases technique, not 1 of them.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -