PHP JSON String, escape Double Quotes for JS output

后端 未结 7 1128
旧时难觅i
旧时难觅i 2020-11-29 04:44

I\'m creating a JSON string from a PHP array. I\'ve encoded it using json_encode().

$data = array(
    \'title\' => \'Example string\\\'s wit         


        
7条回答
  •  自闭症患者
    2020-11-29 05:27

    I just ran into this problem and the actual issue was that I forgot to add a proper application/json header before spitting out the actual JSON data.

    header('Content-Type: application/json');
    

提交回复
热议问题