PHP - 捕获所有POST变量

Is there a way in PHP to capture all post and get variables that are sent to a page?

I am testing my PayPal Subscription website in the PayPal Sandbox but every transaction I do triggers the invalid transaction in my code.

So, I would like to capture everything that PayPal sends to my ipn page and see if I can make sense of what is going on. Is this possible?

Thanks!

For a PayPal IPN, you should be able to use $postdata = file_get_contents('php://input'); to fetch the raw post data needed for the validation callback.

You have $_REQUEST which is a combination of $_GET and $_POST.

http://php.net/manual/en/reserved.variables.request.php

Post values are in the $_POST array.

Get values are in the $_GET array.

Get, post and cookie values are placed in $_REQUEST

Simply save and/or print the contents of those arrays as needed.

For more detailed info, check out:

http://php.net/manual/en/language.variables.superglobals.php

Yes.

On your IPN page, you can log all get, post and cookie variables pretty easy.

Try this:

ob_start();
print_r($_REQUEST);
$data = ob_get_contents();
ob_end_clean();

file_put_contents("Path/to/log.file",$data);

I've got a simple method that helps me capture all the post data:

$post_vars = "";
if ($_POST) {
    $kv = array();
    foreach ($_POST as $k => $v) {
        if (is_array($v)):
            $temp = array();
            foreach ($v as $v2) {
                $temp[] = $v2;
            }
            $kv[] = "$k=" . join("|", $temp);
        else:
            $kv[] = "$k=$v";
        endif;
    }
    $post_vars = join("&", $kv);
}

This allows you to capture all the post data (regardless of its name or value) and then store than in a string, great for inserting into a database, though you might want to url encode it. I've updated it to include support for arrays but you'll have to customise it for your own requirements, it produces output like this:

firstname=Terry&lastname=Kernan&userid=111111&device=999999999&text=Hello&questions=q1|q2|q3&answers=a1|a2|a3&type=manual

<?php  
$req = 'What i reveive from paypal=====';          
foreach ($_POST as $key => $value) // Loop through the key value pairs
    {         
        $req .= "
$key=$value";                    // Add the key value pairs to the variable
    }
        mail('<Your own email address>','Data',$req,'from: <any email address of your own domain>');//mail yourself    
?>