search
HomeBackend DevelopmentPHP7Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)

apache_event_php-fpm Schematic diagram:

Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)

nginx-php-fpm Schematic diagram:

Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)Worker-Master-Server

Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)

TCP-Nginx_PHP

Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)

Nginx-FastCGI

Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram)

1. Use $_GET to get all parameters. php7 will have one more parameter: _url, such as the accessed address

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

At this time, the parameter _url = "Home/String/index2"

2. In PHP7, it is an Error: PHP Notice: Undefined index: HTTP_USER_AGENT in line 2

php5.9 is a 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

Solution: 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 merge operator, PHP7 officially added the ?? operator:

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

4. php-fpm The consequences of not starting

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': 没有那个文件或目录

After working on it for a long time, it turns out that php-fmp has not started. The most important thing is to persist and believe in yourself.

Related Recommended: "PHP Tutorial"

The above is the detailed content of Some pitfalls encountered when upgrading PHP5.9 to PHP7 (php-fpm diagram). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:cnblogs. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),