Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP dump $_REQUEST to file

Tags:

php

I want to dump request variables to a file for debugging. How's this possible?

like image 328
Jamie Redmond Avatar asked Jul 25 '10 05:07

Jamie Redmond


2 Answers

<?php $req_dump = print_r($_REQUEST, TRUE); $fp = fopen('request.log', 'a'); fwrite($fp, $req_dump); fclose($fp); 

Untested but should do the job, just change request.log to the file you want to write to.

like image 68
46bit Avatar answered Sep 20 '22 13:09

46bit


I think nowadays this method is easier and faster:

$req_dump = print_r($_REQUEST, true); $fp = file_put_contents('request.log', $req_dump, FILE_APPEND); 
like image 40
Peon Avatar answered Sep 17 '22 13:09

Peon