PHP json_encode and javascript functions

后端 未结 9 1451
别跟我提以往
别跟我提以往 2020-12-06 04:28

I need to encode a javascript function into a JSON object in PHP.

This:

$function = \"function(){}\";
$message = \"Hello\";

$json = array(   
               


        
9条回答
  •  囚心锁ツ
    2020-12-06 04:47

    No. JSON spec does not support functions. You can write your own code to output it in a JSON-like format and it should work fine though.

提交回复
热议问题