Skip to content

Instantly share code, notes, and snippets.

@coccoinomane
Last active June 6, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coccoinomane/2eae82be7d5b4c35dbfd73fcf5c7eefb to your computer and use it in GitHub Desktop.
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.
<?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