Php 标题位置第二次对链接进行编码

Php 标题位置第二次对链接进行编码,php,redirect,header,urlencode,Php,Redirect,Header,Urlencode,我对编码有问题 我有一个数组: Array ( [pg_salt] => 52f1ef56308ae [pg_merchant_id] => 82 [pg_order_id] => 22 [pg_lifetime] => 86400 [pg_amount] => 501.00 [pg_description] => order number #22 [pg_user_phone] => 792131

我对编码有问题

我有一个数组:

Array
(
    [pg_salt] => 52f1ef56308ae
    [pg_merchant_id] => 82
    [pg_order_id] => 22
    [pg_lifetime] => 86400
    [pg_amount] => 501.00
    [pg_description] => order number #22
    [pg_user_phone] => 79213123763072
    [pg_user_contact_email] => t.muradyan@test.ru
    [pg_user_mail] => t.muradyan@test.ru
    [pg_site_url] => http://bitrix.local
    [pg_check_url] => http://bitrix.local/n/check.php
    [pg_result_url] => http://bitrix.local/n/result.php
    [pg_request_method] => POST
    [pg_success_url] => http://bitrix.local/n/success.php
    [pg_refund_url] => http://bitrix.local/n/refund.php
    [pg_success_url_method] => AUTOPOST
    [pg_failure_url] => http://bitrix.local/n/failure.php
    [pg_failure_url_method] => POST
    [pg_sig] => 6bd3ff87a38a123876841e4312d6f9cb
)
然后我通过以下方式将其转换为查询字符串:

$strQuery = http_build_query($arrRequest)
$strQuery值

pg_salt=52f1ef56308ae&pg_merchant_id=82&pg_order_id=22&pg_lifetime=86400&pg_amount=501.00&pg_description=order+number+%2322&pg_user_phone=79163763072&pg_user_contact_email=t.muradyan%40platron.ru&pg_user_mail=t.muradyan%40platron.ru&pg_site_url=http%3A%2F%2Fbitrix.local&pg_check_url=http%3A%2F%2Fbitrix.local%2Fplatron%2Fcheck.php&pg_result_url=http%3A%2F%2Fbitrix.local%2Fplatron%2Fresult.php&pg_request_method=POST&pg_success_url=http%3A%2F%2Fbitrix.local%2Fplatron%2Fsuccess.php&pg_refund_url=http%3A%2F%2Fbitrix.local%2Fplatron%2Frefund.php&pg_success_url_method=AUTOPOST&pg_failure_url=http%3A%2F%2Fbitrix.local%2Fplatron%2Ffailure.php&pg_failure_url_method=POST&pg_sig=6bd3ff87a38a123876841e4312d6f9cb
然后我通过标题位置重定向:

header('location: http://test.ru/test.php?'.$strQuery)
由于两次编码,所以会出现错误(错误无关紧要)。当我进入该链接时,我的查询字符串是:

pg_salt=52f1ef56308ae&pg_merchant_id=82&pg_order_id=22&pg_lifetime=86400&pg_amount=501.00&pg_description=order+number+%252322&pg_user_phone=1112&pg_user_contact_email=test%2540test.ru&pg_user_mail=test%2540test.ru&pg_site_url=http%253A%252F%252Fbitrix.local&pg_check_url=http%253A%252F%252Fbitrix.local%252Fn%252Fcheck.php&pg_result_url=http%253A%252F%252Fbitrix.local%252Fn%252Fresult.php&pg_request_method=POST&pg_success_url=http%253A%252F%252Fbitrix.local%252Fplatron%252Fsuccess.php&pg_refund_url=http%253A%252F%252Fbitrix.local%252Fn%252Frefund.php&pg_success_url_method=AUTOPOST&pg_failure_url=http%253A%252F%252Fbitrix.local%252Fn%252Ffailure.php&pg_failure_url_method=POST&pg_sig=6bd3ff87a38a123876841e4312d6f9cb
如您所见,它编码两次,例如:

http%3A%2F%2Fbitrix.local

我没有在任何地方使用urlencode函数,为什么它是第二次编码,我不知道。我第一次遇到这个问题。

请参阅:

看看:

如果enc_type是PHP_QUERY_RFC1738,则根据»RFC 1738和 application/x-www-form-urlencoded media type,这意味着 空格编码为加号(+)。如果enc_类型为 PHP_QUERY_RFC3986,然后根据»RFC 3986执行编码, 和空间将按百分比编码(%20)

http%253A%252F%252Fbitrix.local