Skip to content

Instantly share code, notes, and snippets.

@moebrowne
Created August 24, 2015 22:43
Show Gist options
  • Select an option

  • Save moebrowne/a780716832686819d557 to your computer and use it in GitHub Desktop.

Select an option

Save moebrowne/a780716832686819d557 to your computer and use it in GitHub Desktop.
Capture All Request Data in PHP
// The directory in which all parts of the request will be stored
$dir = "/tmp/analysis/a-descriptive-directory-name/".date("Y/m/d/Hi.s");
// Create the root directory
mkdir($dir, 0700, true);
// Write copies of the values of all the request related variables to sepratate files
file_put_contents($dir."/_REQUEST", var_export($_REQUEST,true));
file_put_contents($dir."/_COOKIE", var_export($_COOKIE,true));
file_put_contents($dir."/_SERVER", var_export($_SERVER,true));
file_put_contents($dir."/_POST", var_export($_POST,true));
file_put_contents($dir."/_GET", var_export($_GET,true));
file_put_contents($dir."/_FILES", var_export($_FILES,true));
$data = file_get_contents('php://input');
file_put_contents($dir."/input", var_export($data,true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment