<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>';

10-01 07:36