Is there a PHP function or command that runs a function based on a string, array, or similar? Basically, if the string “time” is passed, I want time() to be returned. Ideally, I’d like this to also support passed parameters. I just want this to be for individual functions, though. I DON’T want to eval() an entire block of code, for obvious reasons.
Does anything like this exist–or, preferably–is it native in PHP?
Try call_user_func() http://php.net/manual/en/function.call-user-func.php
The first argument is a string representing the function name. The second argument can be a single argument, or an array of arguments.
Edit:
It will even support native functions like time(), as you asked. Try it out like so: