Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码:
var custID = <?php echo htmlentities( $_GET['custID'] ); ?>;
我在萤火虫中收到错误:
SyntaxError: syntax error [Break On This Error] var custID = <br />
请注意:我没有传递参数 custID。
如果使用,您需要将其指定为字符串htmlentities():
htmlentities()
var custID = '<?php echo htmlentities( $_GET['custID'] ); ?>';
还值得注意的是,您可能需要在字符串中添加斜杠以防止它脱离 JS 中的文字:
var custID = '<?php echo addslashes(htmlentities( $_GET['custID'] )); ?>';