Open utterances-bot opened 9 months ago
If you are just echoing a json object I wouldn't do that manually. Here's how I would do this:
$data = [
'name' => 'John Doe',
'age' => 10,
];
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
How to return multi-line JavaScript code from PHP — Amit Merchant — A blog on PHP, JavaScript, and more
Sometimes, you may wish to return multi-line JavaScript code from PHP along with some variables. For instance, a JavaScript object.
https://www.amitmerchant.com/return-javascript-code-from-php/