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

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>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • PHP解析/语法错误; 以及如何解决这些问题? 17 answers

    我正在使用NGINX和PHP 5.6,升级后似乎无法调试此错误。 我的错误日志显示为:

    2015/12/29 11:57:56 [错误] 928#0: 20485在stderr中发送的FastCGI:“PHP消息 :PHP解析错误:语法错误,第81行的/var/www/magento/htdocs/pub/become/wp-content/themes/become/index.php中的意外'}',同时从上游,客户端读取响应头: 83.110.226.45,server:sss.uat。 .. com,请求:“GET / become / HTTP / 1.1”,上游:“fastcgi:// unix:/ var / run /php-fpm/sss.uat.*..com.sock:“,host:sss.uat。*** .. com”

    这个 是我的PHP

     &lt;?
    if($ sss_article_featuretitle ==“”){?&gt; 
    &lt;?php echo mb_strimwidth(the_title(),0,40  ,'...');?&gt; 
    &lt;?php} else {//第81行
     echo $ sss_article_featuretitle; 
    } 
    ?&gt; 
       
     \  n 

    PHP 5.6文档和一些搜索没有说明为什么这个查询没有过时。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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条)

相关推荐 更多相似问题