uri_to_assoc 问题
这是我的代码
$default = array('location', 'id', 'page');
$url_info = $this->uri->uri_to_assoc(3, $default);
var_dump($url_info);
如果我的网址是
http://localhost/cidbg/test/uritest/location/india/page/8/id/58
那么我的 $url_info 就可以了。
array
'location' => string 'india' (length=5)
'page' => string '8' (length=1)
'id' => string '58' (length=2)
但是当我的 url 是
http://localhost/cidbg/test/uritest/location/india/page//id/58
那么我的 $url_info 就是这样的。
array
'location' => string 'india' (length=5)
'page' => string 'id' (length=2)
58 => boolean false
'id' => boolean false
那里缺少页面变量。实际上我期待页面为 FALSE。有办法实现这个目标吗?我的意思是,如果缺少一个值,那么该名称应该是错误的。
This is my code
$default = array('location', 'id', 'page');
$url_info = $this->uri->uri_to_assoc(3, $default);
var_dump($url_info);
If my url is
http://localhost/cidbg/test/uritest/location/india/page/8/id/58
Then my $url_info is ok.
array
'location' => string 'india' (length=5)
'page' => string '8' (length=1)
'id' => string '58' (length=2)
But when my url is
http://localhost/cidbg/test/uritest/location/india/page//id/58
Then my $url_info is like this.
array
'location' => string 'india' (length=5)
'page' => string 'id' (length=2)
58 => boolean false
'id' => boolean false
The page variable is missing there. Actually am expecting page to FALSE. Is there anyway to achive this? I mean if a value is missing, then that name should be false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apache 会自动将双斜杠转换为单斜杠。所以
http://localhost/cidbg/test/uritest/location/india/page//id/58
与http://localhost/cidbg/test/uritest/location/ 相同india/page/id/58
因此,您可以使用 .htaccess 搜索一种复杂的方法来保留双斜杠(我不确定这是否可能),或者您可以传递一个额外的参数(例如 0)的空。
http://localhost/cidbg/test/uritest/location/india/page/0/id/58
Apache will automatically convert double slash to a single slash. So
http://localhost/cidbg/test/uritest/location/india/page//id/58
is same ashttp://localhost/cidbg/test/uritest/location/india/page/id/58
So you can either search for a complicated way to retaining the double slash using .htaccess (I'm not sure if that's possible) or you can pass an extra param (like 0) instead of empty.
http://localhost/cidbg/test/uritest/location/india/page/0/id/58