例如,測試代碼:PHP + HTML錯誤;顯示PHP代碼,而不是處理它
<HTML>
<BODY>
<?php
$connect = mysql_connect("localhost", "root", "password") or
die ("Hey loser, check your server connection.");
mysql_select_db("school");
$quey1="select * from student";
$result=mysql_query($quey1) or die(mysql_error());
?>
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Student Record</EM></caption>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Class</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['stud_id'];
echo "</td><td>";
echo $row['stud_name'];
echo "</td><td>";
echo $row['stud_class'];
echo "</td></tr>";
}
echo "</table>";
?>
</BODY>
</HTML>
給我:
我也經歷了錯誤,使用不工作,而世界你好「;?>在html頁面將顯示'hello world';?>'在頁面上。 不知道什麼是錯的......任何人都有線索?
答案指出你試圖直接調用腳本。您必須通過網絡服務器訪問它。最新的PHP有一個內置的網絡服務器。 http://php.net/manual/en/features.commandline.webserver.php – Martin 2012-03-08 03:36:23
爲什麼哦爲什麼開發者會把它放在?猜測它可能對初學者有幫助。 – Corbin 2012-03-08 03:39:19