且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

包含PHP代码的Javascript字符串变量

更新时间:2023-02-18 20:47:30

只是一个猜测...将php括号替换为HTML实体(& lt和& gt;),因此它不会被解释为PHP代码(如果您通过PHP运行包含JS的文件)或浏览器将其作为奇怪的HTML代码(浏览器将括号搜索为html标签,请记住...).

Just a guess... replace the php brackets with HTML entities (< and >) so it will not be interpreted as PHP code (if you run the file containing the JS through PHP) nor as strange HTML code (the browser searches for brackets as html tags, remember...) by the browser.