Syntax error converting to NGINX, unexpected 'elseif' (T

This snippet of code seemed to have been working in Apache but when switching over to NGINX I receive an 500 internal server error. In my nginx logs I get

PHP message: PHP Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in /var/public_html/app/design/frontend//template/seorich/review/summary.phtml on line 51" while reading response header from upstream,

It's referencing this code

<?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; ?>

Here's the Entire success page

<?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; ?>

You need an if statement first to use elseif . Did you mean to just have if ($this->getDisplayIfEmpty()) ? What is the code before that?


So turns out the resulting problem was in short_open_tags - any code with a php short tag

<?

must be converted to

<?php

therefore the multiple lines above was preventing this from happening. After modifying them my errors are gone and it's now functioning as it should.

链接地址: http://www.djcxy.com/p/69844.html

上一篇: 嵌套的php代码导致PHP代码里面的错误

下一篇: 语法错误转换为NGINX,意外的'elseif'(T