PHP urlencode问题,我的字符串中有一个参数:“&notify_url”错误地返回了“¬ify_url”

问题描述 投票:0回答:2

所以当我在以下字符串上使用PHP的urlencode时,似乎出现了一种技术上的问题,我think位于保留的PHP单词“ &not”上。

原始字符串:

cancel_url=https://example.com/payment_cancelled&notify_url=https://example.com/order_notify

我使用urlencode得到以下结果:

cancel_url=https%3A%2F%2Fexample.com%2Fpayment_cancelled¬ify_url=https%3A%2F%2Fexample.com%2Forder_notify

如上所述,它创建了'¬'特殊字符(紧接单词'cancelled'之后)。因此在我看来,“&notify_url”的“&not”部分是操作员保留的操作员词(在PHP中是“&not”?)。

我在如下所示的URL编码后尝试了PHP的str_replace函数:

$paramUrlString = str_replace('¬', '&not', $paramUrlString);
$paramUrlString = str_replace('&#170', '&not', $paramUrlString);

(也尝试对该特殊字符使用ASCII码)

我现在已经没有想法了。请协助,谢谢。

php string special-characters urlencode
2个回答
0
投票

urlencode通常通常根本不会替换&not,但是会用&替换%26。在此处查看示例:http://sandbox.onlinephpfunctions.com/code/e9d62797d01f8162170e5ad5181e14fc339faa52

您可以在urlencode之前尝试用&替换%26。>>

$urlString = str_replace('&', '%26', $urlString);

0
投票

并不是PHP中的任何东西都用&not代替了字符串¬,而是您用来查看/显示数据的任何东西都在执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.