I am attempting to pass some text from my PHP code to Javascript through HTML. It works fine unless the text has a single quote. Here is how I am doing it:
<script>
var t = '<?php echo json_encode(an array containing text "he's here");?>';
</script>
I tried changing the single quotes around the php echo to double quotes. but, of course, JSON uses double quotes, so I had the same problem.
Aucun commentaire:
Enregistrer un commentaire