Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
CakePHP不';t unescape“+&引用;至&引用;在URL中_Url_Cakephp_Escaping - Fatal编程技术网

CakePHP不';t unescape“+&引用;至&引用;在URL中

CakePHP不';t unescape“+&引用;至&引用;在URL中,url,cakephp,escaping,Url,Cakephp,Escaping,我正在开发一个使用标准CakePHP URL模式的CakePHP应用程序 如果我在控制器中使用以下功能: class IndexController extends AppController { public $uses = false; public function test($a) { var_dump($a); } } 并使用以下URL调用它: http://server/index/test/Hello+%2BTest 我得到这个结果: s

我正在开发一个使用标准CakePHP URL模式的CakePHP应用程序

如果我在控制器中使用以下功能:

class IndexController extends AppController {
    public $uses = false;
    public function test($a) {
        var_dump($a);
    }
}
并使用以下URL调用它:

http://server/index/test/Hello+%2BTest
我得到这个结果:

string(11) "Hello++Test"
我希望第一个“+”不替换为“”。为什么不会发生这种情况?

我想你的意思是“unencode”而不是“unescape”

发生这种情况可能是因为+符号是URL的有效字符。只有URL编码的字符(即%xx)将转换回“可读”字符。(尽管很确定这是由Apache完成的,而不是cake)

如果您想要强制转换,您可以通过PHP函数运行它

发件人:

因此,URL中只能使用字母数字、特殊字符“$-+!*”()、”和用于保留目的的保留字符,而不进行编码


谢谢你的回答。正如您所说的,+符号是URL中的有效字符,因此错误发生在客户端,该客户端的空格编码错误。(我无法使用
urldecode()
,因为这会将两个加号解码为空格)