admin管理员组文章数量:1195282
I am trying to print the string of a PHP variable in a Javascript function.Whenever i use a new line in the string that is stored in the PHP variable, I get this error Uncaught SyntaxError while printing it out in a Javascript function.
I am trying to print the string of a PHP variable in a Javascript function.Whenever i use a new line in the string that is stored in the PHP variable, I get this error Uncaught SyntaxError while printing it out in a Javascript function.
Share Improve this question asked Aug 13, 2017 at 14:30 Jahidul Haque PathanJahidul Haque Pathan 1552 silver badges12 bronze badges 2- 1 Do not post pictures. Paste your code here instead, and show us what you have tried. – Milan Chheda Commented Aug 13, 2017 at 14:30
- ok sir. i am new in stackoverflow.next time i will paste my code.Thanks – Jahidul Haque Pathan Commented Aug 13, 2017 at 14:32
1 Answer
Reset to default 30If you want to declare a string variable across multiple lines, you could use this syntax:
var str = `line 1
line 2
line 3`;
Note the (`) instead of (")/(') double or single quotes. They can't be used to declare multiline string.
Essentially, you will need to write it like this:
jQuery("body").replaceWith(`<?php echo $PHPVARIABLE?>`)
本文标签: javascriptUncaught SyntaxError Invalid or unexpected token for new lineStack Overflow
版权声明:本文标题:javascript - Uncaught SyntaxError: Invalid or unexpected token for new line - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738497410a2090064.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论