I have this string in php
$tagged
and I want to put it in my javacript script inside the ' '
tagName: '',
how do I do this
I have this string in php
$tagged
and I want to put it in my javacript script inside the ' '
tagName: '',
how do I do this
The best way IMHO would be this:
tagName: <?php echo json_encode($tagged); ?>
This way, you don't have to take care of escaping quotes, escape characters or other unwanted signs.
If your view is rendered by PHP:
tagName: '<?= json_encode($tagged)?>',
If your JS code is a part of a PHP view, build the object from PHP:
$jsObject = json_encode(array('tagName' => $tagged'));