ZF2: Get url parameters in controller

后端 未结 4 1596
长发绾君心
长发绾君心 2020-12-08 07:30

I have experienced Zend Framework 1 and I\'ve build some apps with that framework.

Now, I\'m experimenting Zend Framework 2, but I\'m stuck on the url parameters. I\

相关标签:
4条回答
  • 2020-12-08 08:06

    From here:

    $slug = $this->getEvent()->getRouteMatch()->getParam('slug');
    

    More documentation here, but it looks kind of incomplete.

    0 讨论(0)
  • 2020-12-08 08:09

    you can simply use this as well

    $this->params()->fromQuery('slug',null);
    $this->params()->fromPost('slug',null);
    

    I hope it works...

    0 讨论(0)
  • 2020-12-08 08:11

    Or simply:

    $slug= $this->params('slug');
    
    0 讨论(0)
  • 2020-12-08 08:14

    Why not this one:

    $this->params()->fromRoute('slug');
    
    0 讨论(0)
提交回复
热议问题