I am trying to copy the string
$str = '
this
is
my
string';
to a JavaScript variable like so
var str1 = '<?php echo $str ?>';
but when I do, I get an error
Uncaught SyntaxError: Unexpected token ILLEGAL
If you are asking yourself why I'm doing this,
I create a <table> with PHP and insert it to the $str variable and want to later use it in a JavaScript function.
var str1 = <?php echo json_encode($str) ?>;