段落<p>警告框为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>

so I have created my own alert box but the problem is that it doesn't work with php, can you help me?

Please take some time to learn PHP syntax, this is a pretty obvious solution. You need to escape or change the quotes.

Escaping:

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

Change the quotes (have to escape the single quotes still):

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