I am working on a project which has a lot of JavaScript. I think that generating simple strings and putting them between \"
I was trying to make my server do an API call and embed it in a html to have javascript process it.. of course put whatever you want in the echo..
And use this to refer to it in HTML...
The api call should return valid javascript, otherwise add what you need to make it valid; this is often the troublesomepart with working with json from api calls. Stripslashes, trim, and other string functions may be of use .. but often pesky foreign characters seep in and can set off php errors based on your php setup.