您好我正在尝试添加多个课程,同时回应一些HTML,但它似乎不起作用。 PHP如下所示:
echo
"<div class="."alert alert-success"." role="."alert".">
<strong>Well done!</strong> You successfully read this important alert message.
</div>";
输出看起来像这样(使用chrome上的dev工具捕获):
<div class="alert" alert-success="" role="alert">
<strong>Well done!</strong> You successfully read this important alert message.
</div>
它已在警报成功时自动填充=“”,但它看起来像是正式
<div class="alert" alert-success role="alert">
<strong>Well done!</strong> You successfully read this important alert message.
</div>
出于某种原因,警报成功类似乎放在括号后面。我试过移动"
,但它仍然在同一个地方。是否有一些我想念的简单。
答案 0 :(得分:1)
尝试 -
echo
"<div class='alert alert-success' role='alert'>
<strong>Well done!</strong> You successfully read this important alert message.
</div>";
答案 1 :(得分:1)
echo
"<div class='alert alert-success' role='alert'>
<strong>Well done!</strong> You successfully read this important alert message.
</div>";
答案 2 :(得分:1)
实际输出是:
<div class=alert alert-success role=alert>
<strong>Well done!</strong> You successfully read this important alert message.
</div>
原因很简单:PHP中的字符串用双引号括起来,在你的代码中你永远不会在字符串中加上双引号:你用它们来关闭字符串。
要在双引号括起的PHP字符串中使用双引号,您需要通过在其前面添加反斜杠来转义该字符:
echo
"<div class=\"alert alert-success\" role=\"alert\">
<strong>Well done!</strong> You successfully read this important alert message.
</div>";
答案 3 :(得分:0)
问题是双重代码和单个代码,因此无法正常工作。如果你想使用双重代码反斜杠。
class = \&#34; alert alert-success \&#34;角色= \&#34;警报\&#34;
这是成功运行谢谢。
&#34; 做得好!您已成功阅读此重要提示消息&#34;;