Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

http

php

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, a diagnostic tool that spits out exactly what I send to a server.

Does anyone have some code that does this?

like image 941
Spike Williams Avatar asked Jun 28 '10 21:06

Spike Williams


People also ask

How print all form data in PHP?

Simply add echo "<pre>"; before the var_dump() or print_r().

What information can you gather from HTTP headers?

Cookie strings, web application technologies, and other data can be gathered from the HTTP Header. This information can be used when troubleshooting or when planning an attack against the web server.

What is an HTTP GET header?

HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon ( : ), then by its value. Whitespace before the value is ignored.


2 Answers

Lastly:

print_r($_REQUEST); 

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

like image 199
Marco Ceppi Avatar answered Oct 11 '22 16:10

Marco Ceppi


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.

like image 39
Vinko Vrsalovic Avatar answered Oct 11 '22 14:10

Vinko Vrsalovic