【问题标题】:How can I access parameter value from URL in the controller?如何从控制器中的 URL 访问参数值?
【发布时间】:2017-04-25 09:25:30
【问题描述】:

我需要一些有关在 phalcon 框架中传递参数的信息

示例网址:http://localhost/project/vehicle/new/vinno/1323123

vehicleController{
    newAction {
        //get the value of vinno

        // want to send parameter to view
    }
}

【问题讨论】:

    标签: php phalcon url-parameters


    【解决方案1】:

    尝试转储调度程序参数。

    print_r($this->dispatcher->getParams());
    

    以上将根据您的路由器定义为您提供完整的参数数组。 the docs 中有关调度员的更多信息。

    要获取特定的参数值,您可以使用getParam() 方法。

    print_r($this->dispatcher->getParam('your_param_name'));
    

    【讨论】:

    • 我们可以提一下参数名称来获取它的值吗?
    【解决方案2】:

    使用路由参数。并使用$this->view->setVar

    【讨论】:

      猜你喜欢
      • 2017-05-10
      • 2017-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多