How do I go about troubleshooting this weird problem? I updated PHP on my VPS to 5.6.0 and now on this one specific script I am getting these two errors when I didn't get them before, and they really don't give me anything to go by.
<br />
<b>Deprecated</b>: 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 <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />
This script just runs some commands to the status of various services through shell_exec
and returns the response as JSON. It doesn't doesn't use any post data, or even contain $_POST
in the file. The first thing in my script is:
<?php
error_reporting(0);
header('Content-Type: application/json');
I commented out that last line, and still got the warning about modify heading information. I don't have any idea why these errors are coming up when they worked fine on the older version (which was 5.5.16)
You cannot use header() once text has been output to the browser. By doing as it is said in the error message:
set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead
you should get rid of those error outputs.
$HTTP_RAW_POST_DATA
is deprecated (this is causing the problem with the header)
Try this:
<?php
$postdata = file_get_contents("php://input");
?>
Read http://php.net/manual/en/reserved.variables.httprawpostdata.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With