搜索
首页后端开发PHP7PHP5.9 升级到PHP7 遇到的一些坑(php-fpm 图解)

apache_event_php-fpm 示意图:

 b2670a85b923ebe8550815945f7d52a.png

nginx-php-fpm示意图:

361cb1b73f655beaca74f359bb4873e.pngWorker-Master-Server

3106cc7fed066f4d2478a12ad861f33.png

 TCP-Nginx_PHP

16425cd62147bd0b25b402afd62657b.png

Nginx-FastCGI

 6f3b9c6b7eece23612da4b8648ac305.png

1、使用$_GET 获取所有参数,php7 会多出一个参数:_url ,例如访问的地址

http://127.0.0.1/Home/String/index2?a=12&b=19

 此时的的参数_url = "Home/String/index2"

2、在PHP7 中为一个Error:PHP Notice: Undefined index: HTTP_USER_AGENT in line 2 

php5.9则为一个notice 

2017/03/27 10:58:09 [error] 5286#0: *851 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: HTTP_USER_AGENT in /home/UserAgent.php on line 9" while reading response header from upstream

解决:http://stackoverflow.com/questions/16330496/php-notice-undefined-index-http-user-agent-in-line-2

if(!empty($_SERVER['HTTP_USER_AGENT'])){
  $user_agent = $_SERVER['HTTP_USER_AGENT'];    
} else {
  $user_agent = ''; 
}

3、NULL 合并运算符 ,PHP7才正式加入了??这个运算符:

// 获取user参数的值(如果为空,则用'nobody')
$username = $_GET['user'] ?? 'nobody';
// 等价于:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';

 4、php-fpm 没有启动的后果

2017/03/31 20:56:19 [crit] 19288#0: *1 connect() to unix:/var/run/php7.0.9-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, 
server: www.phalcon3.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.0.9-fpm.sock:", host: "127.0.0.1"
tinywan@tinywan:/usr/local/nginx/logs$ ll /var/run/php7.0.9-fpm.soc
ls: 无法访问'/var/run/php7.0.9-fpm.sock': 没有那个文件或目录

搞了半天,原来php-fmp 没有启动,贵在坚持,相信自己.

相关推荐:《PHP教程

以上是PHP5.9 升级到PHP7 遇到的一些坑(php-fpm 图解)的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:cnblogs。如有侵权,请联系admin@php.cn删除

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境