say I had this
$src = "function($message) { echo $message; }"
I'm looking for a way to turn the source as a string into an actual function during runtime, sorta like
$say_message = magic_command($src);
$say_message("hello");
but I haven't found a way to do it.
If you're pondering the purpose, I'm extracting data from a large string. To make it simpler to change the procedure, I created an intermediary language(regex really won't do here) which I'm just eval'ing right now. I figured turning the procedure into a php native function might speed up the processing.. worth a shot. Security is not a concern, I'm the only one using this.
eval()would the function you are looking for: php.net/manual/en/function.eval.php