PHP-回显HTML的多个嵌套引号 [英] PHP - Echoing multiple nested quotes of HTML

查看:46
本文介绍了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

这篇关于PHP-回显HTML的多个嵌套引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆