【问题标题】:Syntax error converting to NGINX, unexpected 'elseif' (T_ELSEIF)转换为 NGINX 的语法错误,意外的 'elseif' (T_ELSEIF)
【发布时间】:2014-11-21 03:21:42
【问题描述】:

这段 sn-p 代码似乎一直在 Apache 中运行,但是当切换到 NGINX 时,我收到 500 内部服务器错误。在我的 nginx 日志中,我得到了

PHP 消息:PHP 解析错误:语法错误,/var/public_html/app/design/frontend//template/seorich/review/summary.phtml 中的意外 'elseif' (T_ELSEIF) 在第 51 行“读取响应标头从上游,

它引用了这段代码

<?php elseif ($this->getDisplayIfEmpty()): ?>
<p class="no-rating"><a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this-       >__('Be the first to review this product') ?></a></p>
  <?php endif; ?>

这是整个成功页面

<?php
/**
 * @author Robogento <support@robogento.com>
 * @package Robogento
* @subpackage SEO Rich
* @url http://robogento.com
    *
 * This code is protected by copyright and you are not allowed to share it, alter it and sell as your   own.
* @copyright  Copyright (c) 2012 Robogento
*/
?>
<?php if ($this->getReviewsCount()): ?>
<div class="ratings">
    <?php if ($this->getRatingSummary()):?>
        <div class="rating-box">
            <div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div>
        </div>
    <?php endif;?>

    <p class="rating-links">


    <!--review property for google rich snippets start-->
    <?php if($this->helper('seorich')->isEnabledAttr("review")):?><!--Check if rich snippet enabled for image-->
        <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                    (<span itemprop="ratingValue"><?php echo sprintf ("%.1f",($this->getRatingSummary()/100)*5);?></span> out of <span itemprop="bestRating">5</span>)
                <a href="<?php echo $this->getReviewsUrl() ?>">
                    <span itemprop="reviewCount"><?=$this->getReviewsCount()?></span>
                    <?php echo $this->__('Review(s)') ?>
                </a>
        </span>
    <?php else: ?>
        <a href="<?php echo $this->getReviewsUrl() ?>">
                    <?=$this->getReviewsCount()?>
                    <?php echo $this->__('Review(s)') ?>
        </a>
    <?php endif; ?>
    <!--review property for google rich snippets end-->



            <span class="separator">|</span>
        <a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Add Your Review') ?></a>


    </p>
</div>



 <?php elseif ($this->getDisplayIfEmpty()): ?>
   <p class="no-rating"><a href="<?php echo $this->getReviewsUrl() ?>#review-form"><?php echo $this->__('Be the first to review this product') ?></a></p>
<?php endif; ?>

【问题讨论】:

  • if 在哪里?您的第二个代码块与您的问题有什么关系?
  • 这是 elseif 之前的代码 - 导致它进入它
  • 请粘贴/var/public_html/app/design/frontend//template/seorich/review/summary.phtml的全部内容
  • 为清楚起见添加了整页

标签: php magento nginx


【解决方案1】:

您首先需要一个if 语句才能使用elseif。你的意思是只有if ($this-&gt;getDisplayIfEmpty())?之前的代码是什么?

【讨论】:

  • 添加了正文中的代码,它是我们用来丰富 google 代码的扩展的一部分
【解决方案2】:

结果问题出在 short_open_tags 中——任何带有 php 短标签的代码

<?

必须转换成

<?php

因此上面的多行阻止了这种情况的发生。修改它们后,我的错误消失了,现在可以正常运行了。

【讨论】:

    猜你喜欢
    • 2013-05-13
    • 2018-10-17
    • 2021-09-04
    • 2010-10-08
    • 2013-05-31
    • 2014-01-03
    • 2011-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多