Paypal 立即购买网址 - PHP
我写这个是为了创建 Buynow 按钮 url,但该 url 没有正确显示。
它与数组内爆有关。我猜
问题就发生在这里:
金额=10.00¤cy_code=美元
<?php
#
# Paypal Buynow Button Url
#
$params = array(
'cmd' => '_xclick',
'business' => '[email protected]',
'item_name' => 'Product',
'amount' => '10.00',
'currency_code' => 'USD',
'return' => 'http://www.stackoverflow.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);
?>
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' => '[email protected]',
'item_name' => 'Product',
'amount' => '10.00',
'currency_code' => 'USD',
'return' => 'http://www.stackoverflow.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);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
¤
是 HTML 特殊字符。如果您要回显 HTML 页面,则在 implode 时,请使用implode('&',$encoded_params)
。这应该可以解决问题。
¤
is an HTML special character. If you are echoing to an HTML page, when you implode, useimplode('&',$encoded_params)
.That should fix the issue.