我的代码:
<form action="action.php" method=”post”>
<p>账号: <input type=”text” name=”username” /></p>
<p>密码: <input type=”text” name=”password” /></p>
<p><input type=”submit” /></p>
</form>放到服务器上提示:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\index.php on line 16
上面第一行代码就是第16行
<form action="action.php" method=”post”>
<p>账号: <input type=”text” name=”username” /></p>
<p>密码: <input type=”text” name=”password” /></p>
<p><input type=”submit” /></p>
</form>放到服务器上提示:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\index.php on line 16
上面第一行代码就是第16行
(有一些内容删掉了)<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0025)http://www.hjwstudio.com/ -->
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16446"></HEAD>
<BODY>
<H1 align=center></H1>
<P align=center></P>
<P align=center><A
href="http://www.csdn.net">http://www.csdn.net</A></P>
<?php
$currtime=time();
$currtimestr=strftime("%H:%M:%S",$currtime);
echo"<P align=center>当前时间是:$currtimestr</P>"
<form action="action.php" method=”post”>
<p>账号: <input type=”text” name=”username” /></p>
<p>密码: <input type=”text” name=”password” /></p>
<p><input type=”submit” /></p>
</form>php?>
<P align=center></P>
<P align=center></P>
<P align=center></P>
<P align=center>All rights reserved.</P></BODY></HTML>
另外你的HTML标签属性有的是用中文全角双引号括起来的,浏览器不能有效识别
例如 <input type=”text” name=”username” /></p>
input的type属性会被认为是 ”text” 而不是 text
比如<form action="action.php" method=”post”>修改成"post"自己检查检查吧,修改后有其他错误再发上来.没有的话就赶紧去吃两个粽子
<form action="action.php" method=”post”>
<p>账号: <input type=”text” name=”username” /></p>
<p>密码: <input type=”text” name=”password” /></p>
<p><input type=”submit” /></p>
</form>php?>
1. echo 最好和 ""分开
echo "内容";
2. 内容要被引号包裹,而你要输出的HTML代码中有双引号,PHP解释器是依靠引号来判断字符串在哪里结束的,因此<form a...之后的内容被当成了PHP代码,而前一句echo 没有以分号结尾,所以产生错误:unexpected T_STRING, expecting ',' or ';'
3. PHP代码段的结束标志是 ?> 不是 php?> 只有开始是 <?php 或 <?(开启短标签的情况下是)
正确的代码:
<?php
$currtime=time();
$currtimestr=strftime("%H:%M:%S",$currtime);
echo '<P align=center>当前时间是:'.
$currtimestr.
'</P>"
<form action="action.php" method="post">
<p>账号: <input type="text" name="username" /></p>
<p>密码: <input type="text" name="password" /></p>
<p><input type="submit" /></p>
</form>';?>
还有16行就是<form action="action.php" method="post”>
这是假象,因为第14行少了个分号,PHP认为语句还没有结束。
echo <<<html
<P align=center>当前时间是:{$currtimestr}</P>
<form action="action.php" method="post">
<p>账号: <input type="text" name="username" /></p>
<p>密码: <input type="text" name="password" /></p>
<p><input type="submit" /></p>
</form>
html;
当然,我没有看你其他的代码,只是这个部分...
端午节愉快!