How to print all information from an HTTP request to the screen, in PHP

后端 未结 9 1910
温柔的废话
温柔的废话 2020-12-08 01:55

I need some PHP code that does a dump of all the information in an HTTP request, including headers and the contents of any information included in a POST request. Basically,

相关标签:
9条回答
  • 2020-12-08 02:35

    A simple way would be:

    <?php
    print_r($_SERVER);
    print_r($_POST);
    print_r($_GET);
    print_r($_FILES);
    ?>
    

    A bit of massaging would be required to get everything in the order you want, and to exclude the variables you are not interested in, but should give you a start.

    0 讨论(0)
  • 2020-12-08 02:36

    Lastly:

    print_r($_REQUEST);
    

    That covers most incoming items: PHP.net Manual: $_REQUEST

    0 讨论(0)
  • 2020-12-08 02:37

    Well, you can read the entirety of the POST body like so

    echo file_get_contents( 'php://input' );
    

    And, assuming your webserver is Apache, you can read the request headers like so

    $requestHeaders = apache_request_headers();
    
    0 讨论(0)
提交回复
热议问题