What is the best way to go about defining a php function and the call to that function, in a string, and then executing that code i.e., eval? I'm trying to get the length of an encoded uri out of a function defined and called in a string.
$json_arr['my_function'] = "function hashfun1($enc_uri) { return strlen($enc_uri); } hashfun1($enc_uri);";
$hash_func = $json_arr['my_function'];
$hash_val = eval($hash_func);
print_r($hash_val); // should be length of encoded uri but displays "Parse error: syntax error, unexpected '%', expecting '&' or T_VARIABLE"
exit;
Thanks.