Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php URL在WordPress中被双重编码_Php_Wordpress_Encoding_Character Encoding_Urlencode - Fatal编程技术网

Php URL在WordPress中被双重编码

Php URL在WordPress中被双重编码,php,wordpress,encoding,character-encoding,urlencode,Php,Wordpress,Encoding,Character Encoding,Urlencode,我有一个自定义用户密码重置页面,它工作正常,发送一封带有唯一URL的电子邮件来重置密码,例如: https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User 当我将URL放入浏览器时,我会被定向到: https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=

我有一个自定义用户密码重置页面,它工作正常,发送一封带有唯一URL的电子邮件来重置密码,例如:

https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User
当我将URL放入浏览器时,我会被定向到:

https://website.org/reset-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%2520User

如果我手动从
%2520
中删除
25
,URL会工作,但我不知道如何防止它对这些字符进行双重编码。

这是因为%20被编码为文本而不是空格

因此,当您生成链接时,它应该是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test User');
而不是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User');
我怀疑您目前正在做类似的事情(或者wordpress正在对其进行编码):

链接本身包含
%20
而不是一个文本空间:

如果要运行两次htmlentities,会发生以下情况:

$test = " ";
$first_try = htmlentities($test); // outputs %20
echo $first_try; // outputs %20
echo htmlentities($first_try); // outputs %2520

%25
%
的实体代码,由于
2
0
不需要编码,它导致:
%2520
这是因为%20被编码为文本而不是空格

因此,当您生成链接时,它应该是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test User');
而不是:

your_function_to_generate_password_link('https://website.org/reset-your-password?action=rp&key=chMOWDgCb8h7eFZZby1w&login=Test%20User');
我怀疑您目前正在做类似的事情(或者wordpress正在对其进行编码):

链接本身包含
%20
而不是一个文本空间:

如果要运行两次htmlentities,会发生以下情况:

$test = " ";
$first_try = htmlentities($test); // outputs %20
echo $first_try; // outputs %20
echo htmlentities($first_try); // outputs %2520
%25
%
的实体代码,由于
2
0
不需要编码,它的结果是:
%2520