查询字符串http%3A%2F%2F变为http%253A%252F%252

时间:2014-02-01 16:17:14

标签: php url uri encode

我的查询字符串符号有问题。

我正在将用户重定向到此链接

payment.php?pg_amount=294.91&pg_check_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fcheck.php&pg_description=order+number+%2339&pg_failure_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Frefund.php&pg_request_method=POST&pg_result_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%3A%2F%2Fofficecorp.ru&pg_success_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%40platron.ru&pg_user_mail=t.muradyan%40platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

但它变成了

https://www.platron.ru/payment.php?pg_amount=294.91&pg_check_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fcheck.php&pg_description=order+number+%252339&pg_failure_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Frefund.php&pg_request_method=POST&pg_result_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%253A%252F%252Fofficecorp.ru&pg_success_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%2540platron.ru&pg_user_mail=t.muradyan%2540platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

字母http%3A%2F%2F变为http%253A%252F%252。

$strQuery = http_build_query($arrRequest);

$strQuery 

pg_amount=294.91&pg_check_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fcheck.php&pg_description=order+number+%2339&pg_failure_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Frefund.php&pg_request_method=POST&pg_result_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%3A%2F%2Fofficecorp.ru&pg_success_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%40platron.ru&pg_user_mail=t.muradyan%40platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

编码存在问题。如何解决?

1 个答案:

答案 0 :(得分:1)

原因是,% - 符号被编码(%的十六进制值为0x25)。

您不必手动编码网址,只需将您的网址(包含所有特殊符号)放入链接中,编码就会自动完成。

之后代码应如下所示:

$strQuery = http_build_query($arrRequest);

$strQuery 

pg_amount=294.91&pg_check_url=http://officecorp.ru/platron/check.php&pg_description=order number #39&pg_failure_url=http://officecorp.ru/platron/failure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http://officecorp.ru/platron/refund.php&pg_request_method=POST&pg_result_url=http://officecorp.ru/platron/result.php&pg_salt=52ed1c15ce83b&pg_site_url=http://officecorp.ru&pg_success_url=http://officecorp.ru/platron/success.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan@platron.ru&pg_user_mail=t.muradyan@platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003