5

$HTTP_RAW_POST_DATA is removed in PHP 7.0. In my application, I also have the following line. What is the alternative I can use for this ?

if (isset($GLOBALS['HTTP_RAW_POST_DATA']) && 
                                  mb_strlen($GLOBALS['HTTP_RAW_POST_DATA']))
1
  • What do you want to achieve with that code? As it does not do anything besides checking for the existance of that variable, you could simply remove it - unless there's more code following this
    – Nico Haase
    Jul 20, 2021 at 12:20

1 Answer 1

11

According to the manual:

In general, php://input should be used instead of $HTTP_RAW_POST_DATA

To get the Raw Post Data:

<?php $postdata = file_get_contents("php://input"); ?>
1
  • 2
    "In general" is the critical failing here. php://input does not work for "multipart/form-data" - which is the only encoding type for which I really need raw data.
    – Pancho
    Mar 27, 2021 at 13:12

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.