Url parameters values with special characters are providing errors in view

本小妞迷上赌 提交于 2019-12-23 03:41:18

问题


I have edited Url manager to provide SEO friendly urls but getting problem when the url have values with special characters such as . or () or - or any other special character

http://localhost/nbnd/search/city/delhi

In city action
var_dump($_GET);

output: array(1) { ["city"]=> string(6) "delhi" } 

but when url is with some special character
http://localhost/nbnd/search/city/north-delhi or
http://localhost/nbnd/search/city/north.delhi or
http://localhost/nbnd/search/city/(north)delhi

In city action
var_dump($_GET);

Output : array(1) { ["north-delhi"]=> string(0) "" } 
and so for other

this change in array values results in error.


回答1:


As you want all sorts of characters, change your rule from the related question/answer:

'<controller:\w+>/<action:\w+>/<city>'=>'<controller>/<action>',
// omit the pattern \w+ from city:\w+

Documentation:

In case when ParamPattern is omitted, it means the parameter should match any characters except the slash /.



来源:https://stackoverflow.com/questions/13893728/url-parameters-values-with-special-characters-are-providing-errors-in-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!