Last active
June 6, 2016 13:53
-
-
Save coccoinomane/2eae82be7d5b4c35dbfd73fcf5c7eefb to your computer and use it in GitHub Desktop.
Print to screen and save to file the most important global PHP variables: _POST, _GET, _SERVER, _FILES, _REQUEST.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Print to screen and save to file the most important global PHP | |
* variables: _POST, _GET, _SERVER, _FILES, _REQUEST. | |
* | |
* As an alternative, consider also the free service http://requestb.in/. | |
* | |
* Created by Guido W. Pettinari on 06/06/2016. | |
* Latest version: https://gist.github.com/2eae82be7d5b4c35dbfd73fcf5c7eefb | |
*/ | |
?> | |
<?php | |
/* We don't want to print the output straight away */ | |
ob_start( ); | |
/* Echo all the useful global variables */ | |
echo "<<<<< _POST >>>>>>" . PHP_EOL; | |
print_r($_POST); | |
echo PHP_EOL . PHP_EOL . PHP_EOL; | |
echo "<<<<< _GET >>>>>>" . PHP_EOL; | |
print_r($_GET); | |
echo PHP_EOL . PHP_EOL . PHP_EOL; | |
echo "<<<<< _SERVER >>>>>>" . PHP_EOL; | |
print_r($_SERVER); | |
echo PHP_EOL . PHP_EOL . PHP_EOL; | |
echo "<<<<< _FILES >>>>>>" . PHP_EOL; | |
print_r($_FILES); | |
echo PHP_EOL . PHP_EOL . PHP_EOL; | |
echo "<<<<< _REQUEST >>>>>>" . PHP_EOL; | |
print_r($_REQUEST); | |
echo PHP_EOL . PHP_EOL . PHP_EOL; | |
/* Store the variables in a string */ | |
$output = ob_get_clean( ); | |
/* Output the string to screen */ | |
echo $output; | |
/* Write the string to file */ | |
file_put_contents('request.txt', $output); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment