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>记录 &nbsp;<a href="topic.php">查看全部&raquo;</a></p>
    <p>&nbsp;</p>
 <!-- 发表灌水表单 --> <!-- 灌水表单END -->
    <p>&nbsp;</p>
    <p>&nbsp;</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>&nbsp;</p>
  <p>&nbsp;</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>&nbsp;</p>
</div>
<!--<?php
EOT;
?>-->如何解决?如何解决?
short_tag_open 是on的。文件的编码都是UTF-8的。

解决方案 »

  1.   

    <!--<?php
    print <<<EOT
    ?>-->
    在这根本就不对
    把<!--<?php和?>-->去掉
    包括这个的
    <!--<?php
    EOT;
    ?>-->
      

  2.   

    但是我的另外一个这样写为什么没有报错啊?
    include tpl.'ip.html';在ip.html中就有<!--<?php print<<<EOT
    ?>-->
    <!--<?PHP
    EOT;
    ?>-->这个是怎么会是啊?
      

  3.   

    如果不要就直接刪掉,這種可能會引起用注釋HTML的方法來注釋PHP
      

  4.   

    index.html文件中的“EOT;”必须顶行写。
      

  5.   

    即使 结束标志“EOT;”所在行的前面不能有什么字符(包括空白字符),否则视为未结束.
      

  6.   

    conn.php
    <?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(" ", "&nbsp;", $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 帮忙解决,不胜感激
      

  7.   

     $query=mysql_query($SQL,$conn);
      

  8.   

    我回复 #7楼
    最后3行修改成 <?php
    }
    ?>就可以了!
      

  9.   

    我继续回复 #7楼的问题
    作为一个PHP新手 我希望你还是不要去节省敲打键盘最好按规范去写PHP代码
    <?php /*code*/?>不要省略PHP 我看你上面的代码 报错 提示没有}结尾,很明显你的服务器不支持PHP简写所以最后3行  按下面这样写
    <?php }?>
    然后你还需要修正 输出部分 标题:<?php echo strip_tags($row[title])?>即可  如果你用 <?=$row[title]?> 这么写我敢保证输出的为空 除非您的PHP环境支持简写