Paypal Buy Now Url - PHP
I wrote this to create Buynow button urls, but the url isn't coming out correctly.
It has something to do with imploding the array.. I guess
The problem is occurring here:
amount=10.00¤cy_code=USD
<?php
#
# Paypal Buynow Button Url
#
$params = array(
'cmd' => '_xclick',
'business' => 'someone@gmail.com',
'item_name' => 'Product',
'amount' => '10.00',
'currency_code' => 'USD',
'return' => 'http://www.stacko开发者_JAVA百科verflow.com',
);
$encoded_params = array();
foreach ($params as $k => $v){
$encoded_params[] = $k.'='.urlencode($v);
}
echo $url = "https://www.paypal.com/cgi-bin/webscr?".implode('&', $encoded_params);
?>
¤
is an HTML special character. If you are echoing to an HTML page, when you implode, use implode('&',$encoded_params)
.
That should fix the issue.
精彩评论