【发布时间】:2011-01-21 21:19:37
【问题描述】:
我在用 urlencoded 字符串“%2B”替换“+”号时遇到了一些问题。我该怎么做?
这是我尝试过的:
文本输入到文本框中:
plus(+)
然后我对字符串进行urlencode:
$string = urlencode($string);
字符串现在看起来像:
plus%28+%29
我想要“+” urlencoded,否则当我 urldecode() 显示在浏览器中的数据时,我最终会得到:
plus( )
因为 urldecode() 将“+”解释为空格。
我尝试使用 php 的 str_replace(),但我不断得到一个“NULL”作为“$new_string”的值返回:
$new_string = str_replace('+', '%2B', $string);
有什么想法吗?
提前致谢!
【问题讨论】:
-
为我使用
urlencode($string)echosplus%28%2B%29。