Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug and inspect $_POST

Tags:

php

Lets say that i have 2 pages: index.php and service.php

index.php sends an http-post to service.php, containing a datestamp once every 5th minute.

How would i debug the post variables on service.php? Obviously i cant just do a

if(isset($_POST['key'])) { 
    var_dump($_POST['key']); 
} 

since it wont exist when i enter the page.

In ASP.NET i would just create a breakpoint, but how would i inspect the posted data in php?

Thanks

like image 260
Johan Avatar asked Jun 19 '12 20:06

Johan


1 Answers

Save the status of the $_POST array to a file using var_export (with the current time() to avoid overwrites), and inspect the file later.

file_put_contents( 'debug' . time() . '.log', var_export( $_POST, true));
like image 128
nickb Avatar answered Oct 26 '22 23:10

nickb