PHP-回显HTML的多个嵌套引号
问题描述:
我正在尝试通过PHP回显HTML的下一行
I'm attempting to echo the following line of HTML through PHP
echo "<a class='fa fa-ban fa-2x cancelClass' onClick='cancelClass('$id', '$formattedDate', '$time')'></a><p class='text-center'>".$formattedDate." @ $time</p>";
我没有收到错误消息.但是onClick ='cancelClass ...的引号无法正确解析,这导致javascript函数无法执行.
I don't get an error. But the quotes for onClick='cancelClass... don't get parsed properly, which leads to the javascript function not executing.
它如何在Google Chrome Source View中进行颜色编码
How it gets color coded in Google Chrome Source View
应如何对其进行颜色编码(另一个功能的示例)
How it should get color coded (example of another function)
答
将其更改为以下内容
echo "<a class=\"fa fa-ban fa-2x cancelClass\" onClick=\"cancelClass('$id', '$formattedDate', '$time')\"></a><p class=\"text-center\">".$formattedDate." @ $time</p>";
将属性双引号转义,您可以使用规范化的html
escaping the attribute double quotes you can have a normalized html