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
Post a Comment