段落<p> 警告框作为回显?

Paragraph <p> alert box as echo?

<p class="alert-danger"><strong>Achtung!</strong> This alert box indicates a dangerous or potentially negative action.<span class="alert-danger-closebtn" onclick="this.parentElement.style.display='none';">&times;</span></p>

所以我创建了自己的警告框,但问题是它不适用于 php,你能帮我吗?

请花点时间学习 PHP 语法,这是一个非常明显的解决方案。您需要转义或更改引号。

转义:

echo "<p class=\"alert-danger\"><strong>DANGER!</strong> This alert box indicates a dangerous or potentially negative action.<span class=\"alert-danger-closebtn\" onclick=\"this.parentElement.style.display='none';\">&times;</span></p>";

更改引号(仍然必须转义单引号):

 echo '<p class="alert-danger"><strong>DANGER!</strong> This alert box indicates a dangerous or potentially negative action.<span class="alert-danger-closebtn" onclick="this.parentElement.style.display=\'none\';">&times;</span></p>';