dstt1818 2015-12-29 12:02
浏览 74
已采纳

PHP使用Nginx和FastCGI解析错误[重复]

This question already has an answer here:

I am using NGINX and PHP 5.6 and cannot seem to debug this error after an upgrade. My error log reads:

2015/12/29 11:57:56 [error] 928#0: 20485 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected '}' in /var/www/magento/htdocs/pub/become/wp-content/themes/become/index.php on line 81" while reading response header from upstream, client: 83.110.226.45, server: sss.uat...com, request: "GET /become/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/sss.uat.*..com.sock:", host: sss.uat.***..com"

And this is my PHP

<?
if($sss_article_featuretitle==""){?>
    <?php echo mb_strimwidth(the_title(), 0, 40, '...'); ?>
<?php } else { //line 81
    echo $sss_article_featuretitle;
}
?>

The PHP 5.6 docs and some searching does not say why this query is no obsolete.

</div>
  • 写回答

2条回答 默认 最新

  • donglu8779 2015-12-29 12:07
    关注

    Remove all excess open/close tags:

    <?php
    if ($sss_article_featuretitle=="") {
        echo mb_strimwidth(the_title(), 0, 40, '...');
    } else {
        echo $sss_article_featuretitle;
    }
    ?>
    

    Update: Try to change it like this:

    http://php.net/manual/en/language.basic-syntax.phpmode.php

    <?php if ($sss_article_featuretitle==""): ?>
      <?php echo mb_strimwidth(the_title(), 0, 40, '...'); ?>
    <?php else: ?>
      <?php  echo $sss_article_featuretitle; ?>
    <?php endif; ?>
    

    Also make sure you don't use short open tag <?, which is not a good practice and is probably disabled in PHP settings, so should be turned on by short_open_tag directive in your php.ini file.

    http://php.net/manual/en/language.basic-syntax.phptags.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 关于加载卡的问题有能知道这个要怎么处理吗?
  • ¥100 rtmpose姿态评估
  • ¥15 java 通过反射找路径下的类,打包后就找不到
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错
  • ¥15 hbuildex运行微信小程序报错
  • ¥15 关于#python#的问题:我知道这个问题对你们来说肯定so easy
  • ¥15 wpf datagrid如何实现多层表头
  • ¥15 为啥画版图在Run DRC会出现Connect Error?可我Calibre的hostname和计算机的hostname已经设置成一样的了。