加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 斜杠的ZF2路由参数

发布时间:2020-12-13 17:16:44 所属栏目:PHP教程 来源:网络整理
导读:是否可以使用包含正斜杠的参数组装路径? 配置: 'someroute' = array( 'type' = 'ZendMvcRouterHttpSegment','options' = array( 'route' = 'someroute/:path','defaults' = array( 'controller' = 'Controller','action' = 'index' ),'constraints' =
是否可以使用包含正斜杠的参数组装路径?

配置:

'someroute' => array(
       'type' => 'ZendMvcRouterHttpSegment','options' => array(
                'route' => 'someroute/:path','defaults' => array(
                    'controller' => 'Controller','action' => 'index'
                ),'constraints' => array(
                    'path' => '(.)+'
                )
       )
 )

控制器:

$path = 'some/subdirectory';
$this->url('someroute',array('path' => $path));

结果是:

http://host.name/someroute/some%2Fsubdirectory

解决方法

在视图中使用rawurldecode()当然可以解决这个问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读