Since the emergence of php7 has brought about significant performance improvements, I wanted to experience the features brought by the new version, so I upgraded.
Found that an error occurred when requesting the interface in the website, and recorded the solution after troubleshooting
After upgrading php, the site reported an error, the prompt is as follows:
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set ‘always_populate_raw_post_data‘ to ‘-1‘ in php.ini and use the php://input stream instead. in Unknown on line 0 Warning: Cannot modify header information - headers already sent in Unknown on line 0
After checking the php official website, we learned that some features have been abandoned in php5.6.X and later versions. For details, check:
http://php.net/manual/zh /migration56.deprecated.php
The reason is:
$HTTP_RAW_POST_DATA 和 always_populate_raw_post_data
Using always_populate_raw_post_data will cause an E_DEPRECATED error when filling $HTTP_RAW_POST_DATA.
Please use php://input instead of $HTTP_RAW_POST_DATA as it may be removed in subsequent PHP versions.
Set always_populate_raw_post_data to -1 (this will force $HTTP_RAW_POST_DATA to be undefined, so it will not cause E_DEPRECATED errors) to experience the new behavior.
Repair method:
1. Modify the php configuration file and find php.ini. Turn on always_populate_raw_post_data and set it to -1.
always_populate_raw_post_data = -1
2. If $HTTP_RAW_POST_DATA is useful in the project, change it to:
It turns out to be $info = $HTTP_RAW_POST_DATA;
Change it to $info = file_get_contents( 'php://input');
Recommended: "PHP7"
The above is the detailed content of About error handling after upgrading php7. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)