Debug and check $ _POST

Suppose I have 2 pages: index.php and service.php

index.php sends an http message to service.php containing the datestamp once every 5 minutes.

How to debug post variables on service.php? Obviously i can't just do

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

as it does not exist when I enter the page.

In ASP.NET, I would just create a breakpoint, but how would I check the published data in php?

thank

+5
source share
5 answers

Save the state of the array $_POSTto a file using var_export(with the current time()one to avoid overwriting), and check the file later.

file_put_contents( 'debug' . time() . '.log', var_export( $_POST, true));
+7
source

post var_dump print_r, , , " "

:

  • TamperData -

  • HttpFox - http-

  • Firebug, . "" :

    Firebug - .

  • Firebug ; FirePHP, Firebug. , FirePHP , .

  • : Chrome (F12) Firefox (CTRL + SHIFT + K)

  • error_log:

    error_log ( "\n".serialize($ _ POST), 3, "/var/tmp/my-errors.log" );

Documentation

PHP var_dump - http://php.net/manual/en/function.var-dump.php

PHP print_r - http://php.net/manual/en/function.print-r.php

PHP error_log - http://php.net/manual/en/function.error-log.php

Firebug FirePHP - http://sixrevisions.com/web-development/how-to-debug-php-using-firefox-with-firephp/

+5

print_r .

echo '<pre>';
print_r($_POST);
+1

Since you are responding to an internal request made by another PHP script on the server, you have several options: write it tosyslog , register it in your own log file or in the database, or send an email somewhere.

+1
source

for php (applicable to many IDEs, you will need to configure your specific IDE), you can use xdebug to set breakpoints and check your variables

0
source

All Articles