Home > Article > Backend Development > Why Does PHP 5.6 Issue a Deprecation Warning for `$HTTP_RAW_POST_DATA` and How Can I Fix It?
PHP 5.6's Deprecation Warning: Uncovering the Confusion Surrounding $HTTP_RAW_POST_DATA
Upon upgrading to PHP 5.6.0, many developers encounter a persistent warning: "Automatically populating $HTTP_RAW_POST_DATA is deprecated..." However, the common assumption that this warning is triggered by using the $HTTP_RAW_POST_DATA variable is inaccurate.
The root cause of the warning lies in the configuration value always_populate_raw_post_data, which defaults to 0. Despite its name, setting this value to 0 does not fully disable the population of $HTTP_RAW_POST_DATA. Instead, it only prevents population when the content-type is registered or when the request method is not POST.
According to the PHP RFC, setting always_populate_raw_post_data to -1 "completely disables populating $GLOBALS[HTTP_RAW_POST_DATA], which is what many developers seek to achieve when encountering this warning.
To solve the problem at its source and suppress the warning, set always_populate_raw_post_data to -1 in php.ini. This does more than hide the warning; it prevents PHP from populating $HTTP_RAW_POST_DATA, eliminating the deprecated configuration.
The above is the detailed content of Why Does PHP 5.6 Issue a Deprecation Warning for `$HTTP_RAW_POST_DATA` and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!