StevenOliver Posted April 8, 2020 Share Posted April 8, 2020 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! Quote Link to comment Share on other sites More sharing options...
gw1500se Posted April 8, 2020 Share Posted April 8, 2020 echo "<pre>"; var_dump(getallheaders()); echo "</pre>"; Quote Link to comment Share on other sites More sharing options...
requinix Posted April 9, 2020 Share Posted April 9, 2020 And learn about $_SERVER. Quote Link to comment Share on other sites More sharing options...
StevenOliver Posted April 10, 2020 Author Share Posted April 10, 2020 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"; } } Quote Link to comment Share on other sites More sharing options...
requinix Posted April 10, 2020 Share Posted April 10, 2020 Instead of trying to print it yourself, use print_r() or var_dump(). They exist specifically for this purpose. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 11, 2020 Share Posted April 11, 2020 For increased readability, use them between <pre>..</pre> tags E.G. echo '<pre>' . print_r($_SERVER, true) . '</pre>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.