-2

所以当我在谷歌浏览器中打开它时,我继续收到以下错误:

此页面包含以下错误:

第 60 行第 28 列的错误:属性值中不允许未转义的 '<' 下面是第一个错误之前的页面呈现。

但是我看到很多人以这种方式获取 IP 地址的例子。我究竟做错了什么?

    <?xml version="1.0" encoding="UTF-8"?>
 <!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" xml:lang="en" lang="en">
<head>
<title>GradeYourTeacher.Com</title>
<style type="text/css">
p{
    color:black;
    f ont-size:14pt;
    font-family: "Comic Sans MS", cursive, sans-serif;
}
h1 {
    color:purple;
    text-align:center;
    font-size:36pt;
    font-family: "Trebuchet MS", Helvetica, sans-serif;
}
</style>
</head>
<!--This Website is made by Francisco Sanchez-->
<!--Try to get IP Address echo $_SERVER['REMOTE_ADDR'];  -->
<body>
<h1>Grade Your Teacher</h1>
<p>
<form id="myform" action="http://learncompsci.com/web/examples/forms/formReader.php" method="get">
To Grade Your Teacher Please Enter The Following Information:
<br/>
<br/>
Display Name: &nbsp; <input name="loginName" type="text" id="loginName" size="14" maxlength="32"/> (For others to view)
<br/>
Email: &nbsp; <input name="email" type="text" id="email" size="20" maxlength="64"/>
<br/>
Email: &nbsp; <input name="password" type="password" id="password" size="14" maxlength="32"/>
<br/>
Confirm Password: &nbsp; <input name="passwordConfirm" type="password" id="passwordConfirm" size="10" maxlength="20" /><br />
First Name:: &nbsp; <input name="firstName" type="text" id="firstName" size="20" maxlength="40" /><br />
Grad Year:: &nbsp; <select name="gradYear" id="gradYear">
      <option value="08">2008</option>
      <option value="09">2009</option>
      <option value="10">2010</option>
      <option value="11">2011</option>
    </select><br />
Gender:: &nbsp; <input name="gender" type="radio" value="male" checked="checked" />
      male &nbsp; &nbsp; 
      <input type="radio" name="gender" value="female" />
      female<br />
Sports: &nbsp; <input type="checkbox" name="sports" value="track" />
      track &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="baseball" />
      baseball &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="lacrosse" />      
      lacrosse &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="paintball" />
paintball
<br />
    Banter: &nbsp; <textarea name="banter" cols="30" rows="5" id="banter"></textarea><br />
    <input type="submit" name="Submit" value="Enter" />
    <input type="hidden" id="IP" name="IP" value= "<?php echo $_SERVER['REMOTE_ADDR']; ?>" />

<br/>
</form>
</p>    
</body>
</html>
4

1 回答 1

2

您需要让 PHP 引擎解析脚本/页面,才能使 PHP 代码正常工作。

或者用更简单的方式说;你需要把它放在你的网络服务器上。

通常,PHP 初学者从便宜的托管解决方案开始,或者- 为了节省费用 - 安装 WAMP,一个简单的安装包,其中包含在本地解析 PHP 的必需品 - Apache(网络服务器),MySQL(数据库),当然还有 PHP 以允许Apache 来解析你的脚本。

尝试使用一些主机或在本地安装一些东西。

于 2012-08-23T05:56:48.250 回答