PHP: Possible to automatically get all POSTed data?

后端 未结 8 1621
Happy的楠姐
Happy的楠姐 2020-11-28 05:20

Simple question: Is it possible to get all the data POSTed to a page, even if you don\'t know all the fields?

For example, I want to write a simple script that colle

8条回答
  •  甜味超标
    2020-11-28 05:52

    As long as you don't want any special formatting: yes.

    foreach ($_POST as $key => $value) 
        $body .= $key . ' -> ' . $value . '
    ';

    Obviously, more formatting would be necessary, however that's the "easy" way. Unless I misunderstood the question.

    You could also do something like this (and if you like the format, it's certainly easier):

    $body = print_r($_POST, true);
    

提交回复
热议问题