【问题标题】:PHP Parse error: syntax error, unexpected end of file in PHP 5.5.9 [duplicate]PHP Parse 错误:语法错误,PHP 5.5.9 中的文件意外结束 [重复]
【发布时间】:2016-07-18 16:38:53
【问题描述】:

我有以下代码:

<?php if ($template['issue']['raw_state'] == 0 && ($helper->user_coordinator($template['issue']['id']) || isset($nparams['tid']))): ?>
    <a href="?id=<?php echo $this->id('cause_form', 'id', $template['issue']['id']) ?>">
        <?php echo $bezlang['add_cause'] ?>
    </a>
<? endif ?>

它在我的大多数服务器上运行良好,但在其中一个服务器上我收到错误:

PHP 解析错误:语法错误,文件意外结束 /var/www/dokuwiki/lib/plugins/bez/tpl/issue_causes.php 在第 19 行,

这段代码有什么问题?

整个文件issue_cause.php:

<?php include "issue_box.php" ?>

<div class="bds_block" id="bez_causes">
    <h1><?php echo $bezlang['causes'] ?> <span>(<?php echo count($template['causes']) ?>)</span></h1>
    <div class="bds_block_content">
        <?php foreach ($template['causes'] as $cause): ?>
            <?php include "cause.php" ?>
        <?php endforeach ?>
    </div>
    <?php if ($template['issue']['raw_state'] == 0 && ($helper->user_coordinator($template['issue']['id']) || isset($nparams['tid']))): ?>
        <a href="?id=<?php echo $this->id('cause_form', 'id', $template['issue']['id']) ?>">
            <?php echo $bezlang['add_cause'] ?>
        </a>
    <? endif ?>
</div>

<?php include "removal_confirm.php" ?>

【问题讨论】:

  • on line 19,但这里只显示 17 行。你确定你在这里向我们展示了正确且真实的文件吗?
  • 你需要在 endofreach 和 endif 之后加一个分号,例如 &lt;?php endforeach; ?&gt;&lt;?php endif; ?&gt;
  • 他没有用过;的任何地方。
  • 确保所有服务器上都启用了短标签。
  • 更多“为什么我的代码不起作用”的问题

标签: php parse-error


【解决方案1】:
Could you replace <? endif ?> with <?php endif ?>

【讨论】:

  • 你是对的。我怎么能忽略这一点?旧的 shot_tag_open 问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-27
  • 2012-12-09
  • 2012-05-16
  • 2016-04-30
  • 2013-01-23
  • 2012-11-03
  • 1970-01-01
相关资源
最近更新 更多