[英]insert string which double quotes in tag html
how could insert double quotes in html tag. 如何在html标签中插入双引号。
example: php code: 示例:php代码:
$con = "the teacher said: \"hello\"";
return in php: 在php中返回:
'<tagname name="'$con'">'
the problem is that it only takes the text until it finds the first double quote 问题是它只使用文本,直到找到第一个双引号
thanks. 谢谢。
$con = "the teacher said: "hello"";
echo '<tagname con="'.$con.'">';
Use a .
使用.
to concentrate strings. 集中弦。 Because you can't include a double quote inside an HTML attribute, even when escaping it in PHP, encode the double quote as "
因为您不能在HTML属性中包含双引号,所以即使在PHP中将其转义,也应将双引号编码为"
, which will show as "
. If you want to do this automatically, run ,将显示为"
。如果要自动执行此操作,请运行
$con = htmlspecialchars($con);
to automatically encode the string. 自动编码字符串。 You can run this inline by using 您可以使用来内联运行
echo '<tagname con="'.htmlspecialchars($con).'">';
PHP manual: htmlspecialchars
PHP手册: htmlspecialchars
Use htmlspecialchars
: 使用htmlspecialchars
:
echo '<tagname name="' . htmlspecialchars($con) . '">'
HTML raw: HTML原始:
<tagname name="the teach said: "hello"">
You have two problems here. 您在这里有两个问题。
.
使用.
htmlspecialchars
使用htmlspecialchars
Such: 这样:
'<tagname name="' . htmlspecialchars($con) . '">'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.