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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器