print <<<EOT 出现提示Parse error: syntax error, unexpected $end in 如何解决?
错误提示Parse error: syntax error, unexpected $end in 出现原因:使用了print<<<EOT文件index.php
templates/default/index.htmlindex.php文件中的内容如下
<?php
include('class/inc.php');
$pagetitle = '灌水天涯!';
include tpl.'incheaderindex.html';
include tpl.'incleft.html'; $html='dd';
$totalNum='023';
include tpl.'index.html';
include tpl.'incfooter.html';
mysql_close($DB->conn);
?>index.html文件中的内容全部如下:<!--<?php
print <<<EOT
?>-->
<div id="right">
$html<p class="meta">共<span class="number"><a href="topic.php" title="查看全部灌水~">$totalNum</a></span>记录 <a href="topic.php">查看全部»</a></p>
<p> </p>
<!-- 发表灌水表单 --> <!-- 灌水表单END -->
<p> </p>
<p> </p>
</div>
<p style="clear:both"></p>
<!--<?php
EOT;
?>-->当去除print <<<EOT 和EOT;的部分,那么就不会出现这个错误提示。
但是在当引入另外一个文件ip.html而不是这个index.html文件的时候,不会出现错误提示。index.php文件中引入templates/default/ip.html
index.php文件中的内容是$ip="120.0.0.0",
会直接执行,IP.html文件中的全部内容如下:<!--<?php
print <<<EOT
?>-->
<div id="header">
<p> </p>
<p> </p>
<p class="logo">您当前的IP为:<strong>$ip</strong></p>
<p>不在被限制的范围中~</p>
<p><hr /></p>
<p>已被禁止的IP地址列表如下:</p>
<table width="100%" border="0" cellspacing="0">
<tr class="dash">
<th>IP地址</th>
<th>开始日期</th>
<th>结束日期</th>
<th>备注/原因</th>
</tr>
<tr>
<td>127.56.*.*</td>
<td>2009-07-12</td>
<td>2009-12-18</td>
<td></td>
</tr>
<tr class="dash">
<td>58.123.*.*</td>
<td>2009-08-03</td>
<td>2009-12-12</td>
<td></td>
</tr>
</table>
<p> </p>
</div>
<!--<?php
EOT;
?>-->如何解决?如何解决?
short_tag_open 是on的。文件的编码都是UTF-8的。
错误提示Parse error: syntax error, unexpected $end in 出现原因:使用了print<<<EOT文件index.php
templates/default/index.htmlindex.php文件中的内容如下
<?php
include('class/inc.php');
$pagetitle = '灌水天涯!';
include tpl.'incheaderindex.html';
include tpl.'incleft.html'; $html='dd';
$totalNum='023';
include tpl.'index.html';
include tpl.'incfooter.html';
mysql_close($DB->conn);
?>index.html文件中的内容全部如下:<!--<?php
print <<<EOT
?>-->
<div id="right">
$html<p class="meta">共<span class="number"><a href="topic.php" title="查看全部灌水~">$totalNum</a></span>记录 <a href="topic.php">查看全部»</a></p>
<p> </p>
<!-- 发表灌水表单 --> <!-- 灌水表单END -->
<p> </p>
<p> </p>
</div>
<p style="clear:both"></p>
<!--<?php
EOT;
?>-->当去除print <<<EOT 和EOT;的部分,那么就不会出现这个错误提示。
但是在当引入另外一个文件ip.html而不是这个index.html文件的时候,不会出现错误提示。index.php文件中引入templates/default/ip.html
index.php文件中的内容是$ip="120.0.0.0",
会直接执行,IP.html文件中的全部内容如下:<!--<?php
print <<<EOT
?>-->
<div id="header">
<p> </p>
<p> </p>
<p class="logo">您当前的IP为:<strong>$ip</strong></p>
<p>不在被限制的范围中~</p>
<p><hr /></p>
<p>已被禁止的IP地址列表如下:</p>
<table width="100%" border="0" cellspacing="0">
<tr class="dash">
<th>IP地址</th>
<th>开始日期</th>
<th>结束日期</th>
<th>备注/原因</th>
</tr>
<tr>
<td>127.56.*.*</td>
<td>2009-07-12</td>
<td>2009-12-18</td>
<td></td>
</tr>
<tr class="dash">
<td>58.123.*.*</td>
<td>2009-08-03</td>
<td>2009-12-12</td>
<td></td>
</tr>
</table>
<p> </p>
</div>
<!--<?php
EOT;
?>-->如何解决?如何解决?
short_tag_open 是on的。文件的编码都是UTF-8的。
print <<<EOT
?>-->
在这根本就不对
把<!--<?php和?>-->去掉
包括这个的
<!--<?php
EOT;
?>-->
include tpl.'ip.html';在ip.html中就有<!--<?php print<<<EOT
?>-->
<!--<?PHP
EOT;
?>-->这个是怎么会是啊?
<?php/*
* PHP100Job v1.0
* Programmer : Msn/QQ [email protected] (925939)
* www.php100.com Develop a project PHP - MySQL - Apache
* Window 2003 - Preferences - PHPeclipse - PHP - Code Templates
*/$conn = @ mysql_connect("localhost", "root", "dong") or die("数据库链接错误");
mysql_select_db("news", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;function htmtocode($content) {
$content = str_replace("\n", "<br>", str_replace(" ", " ", $content));
return $content;
}//$content=str_replace("'","‘",$content);
//htmlspecialchars();
?><?php/*
* PHP100Job v1.0
* Programmer : Msn/QQ [email protected] (925939)
* www.php100.com Develop a project PHP - MySQL - Apache
* Window 2003 - Preferences - PHPeclipse - PHP - Code Templates
*/
include("conn.php"); include("head.php");
$SQL="SELECT * FROM `message` order by id desc";
$query=mysql_query($SQL);
while($row=mysql_fetch_array($query)){
?><table width=500 border="0" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<tr bgcolor="#eff3ff">
<td>标题:<?=$row[title]?> 用户:<?=$row[user]?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?
echo htmtocode($row[content]);
?></td>
</tr>
</table>
<?
}
?>
运行出现下边的错误
Parse error: syntax error, unexpected $end in E:\wamp\www\leave_message\list.php on line 35 帮忙解决,不胜感激
最后3行修改成 <?php
}
?>就可以了!
作为一个PHP新手 我希望你还是不要去节省敲打键盘最好按规范去写PHP代码
<?php /*code*/?>不要省略PHP 我看你上面的代码 报错 提示没有}结尾,很明显你的服务器不支持PHP简写所以最后3行 按下面这样写
<?php }?>
然后你还需要修正 输出部分 标题:<?php echo strip_tags($row[title])?>即可 如果你用 <?=$row[title]?> 这么写我敢保证输出的为空 除非您的PHP环境支持简写