如何在php中输出html代码

html-css018

如何在php中输出html代码,第1张

1、输出HTML

echo '<div>html代码</div>';

2、输出js

echo '<script>alert(123)</script>'

其实很简单,只要把html语句中的双引号改为单引号,然后直接用echo输出就行了:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>无标题文档</title>

</head>

<body>

<ul class="nav navbar-nav navbar-right">

<li class="nli"><a href="/About/">关于我们</a></li>

<li class="nli"><a href="/Notice/">舞蹈</a></li>

<li class="nli"><a href="/Instructors/">师资阵容</a></li>

</li></ul>

<?php

echo("<ul class='nav navbar-nav navbar-right'>")

echo("<li class='nli'><a href='/About/'>关于我们</a></li>")

echo(" <li class='nli'><a href='/Notice/'>舞蹈</a></li>")

echo(" <li class='nli'><a href='/Instructors/'>师资阵容</a></li>")

echo("</li></ul>")

?>

</body>

</html>