I need to encode a javascript function into a JSON object in PHP.
This:
$function = \"function(){}\"; $message = \"Hello\"; $json = array(
As Jani said, this is not possible directly with JSON, but this might help you: http://web.archive.org/web/20080828165256/http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/