I need to encode a javascript function into a JSON object in PHP.
This:
$function = \"function(){}\"; $message = \"Hello\"; $json = array(
The enconding part in PHP is seems to be solved by now. You can use
json_encode($p, JSON_UNESCAPED_UNICODE)
this way your function will not be escaped. However