String operations (Error in PayPal sample scripts?)
Posted: Tue Jul 21, 2009 8:05 pm
I'm a PHP "newbie" and planning to use it to set up an ecommerce website with payment through PayPal.
After the customer pays, PayPal will send me a message("IPN" or "PDT") and requires that I acknowledge it. PayPal provides sample scripts for this purpose (e.g., https://www.paypaltech.com/SG2/). The code to take the incoming message and construct the response includes
Shouldn't that obviously be $req .= &$key . "=" . $value? Or will the code as given somehow give the desired result in PHP?
(Also, can you give me a quick review of what &$key does?)
After the customer pays, PayPal will send me a message("IPN" or "PDT") and requires that I acknowledge it. PayPal provides sample scripts for this purpose (e.g., https://www.paypaltech.com/SG2/). The code to take the incoming message and construct the response includes
Wouldn't the result of this be "cmd=_notify-validate&$key=$value&$key=$value&$key=$value..."?$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
Shouldn't that obviously be $req .= &$key . "=" . $value? Or will the code as given somehow give the desired result in PHP?
(Also, can you give me a quick review of what &$key does?)