Jump to content
StevenOliver

Display all visitor request variables

Recommended Posts

For debug purposes, I want to see all (each and every possible) variables from a website visitor, e.g.
• their user agent (e.g. cURL)
• the reqest string they used (e.g. "https://example.com/product.php?sku=12345")
• their IP address
• and everything else I haven't thought of

I know how to save the info in a database, I might even have the info emailed to myself, I just can't remember the "one-liner" I used to use to capture this info.

Thank you in advance!

 

Share this post


Link to post
Share on other sites
echo "<pre>";
var_dump(getallheaders());
echo "</pre>";

 

Share this post


Link to post
Share on other sites

Thank you both gw1500se and Requinix! The answer from gw1500se was the one I was looking for.... but it ended up not working -- didn't display anything but a blank screen, so maybe some configuration on my server is interfering... The answer from Requinix is important, too -- however, when I tried "print_r($_SERVER)" and just got a blank screen, I gave up..... until (several hours later) it dawned on me that I had to loop through nested arrays. This works for me here:

foreach($_SERVER as $a => $b) {
echo $a;
echo "\n";
echo $b;
echo "\n";
foreach ($b as $c=>$d) {
echo "$c";
echo "\n";
echo "$d";
}
}

 

Share this post


Link to post
Share on other sites

Instead of trying to print it yourself, use print_r() or var_dump(). They exist specifically for this purpose.

Share this post


Link to post
Share on other sites

For increased readability, use them between <pre>..</pre> tags

E.G.

echo '<pre>' . print_r($_SERVER, true) . '</pre>';

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.