我想不出来生成网址来自世界各地,我想,在Zend的2ZF2 - 产生网址从路线
我得到的行动和控制,所以我试试这个:
$this->url('myControllerName', array('action' => 'myActionName'));
但这返回一个对象,我只想要这条路线的完整URL字符串
有人可以帮我找到正确的方法吗?
编辑:根据斯托扬,也许我在我的路线上犯了一个错误。这里是我的module.config
'router' => array (
'routes' => array (
'indexqvm' => array (
'type' => 'segment',
'options' => array (
'route' => '/Indexqvm[/:action][/:id_event]',
'constraints' => array (
'action' => '[a-zA-Z][a-zA-Z0-9_-]+',
'id_event' => '[0-9]+'
),
'defaults' => array (
'controller' => 'Qvm\Controller\Indexqvm',
'action' => 'index'
)
)
),
和我通话的部分:
echo $this->url('indexqvm', array('action' => 'list-index'));
错误: 开捕致命错误:对象类的Zend \的mvc \控制器\插件\ URL不能转换为字符串
谢谢斯托扬为这个快速的回答, 然而,因为我没有得到一个字符串,我不能回应它: 可捕获的致命错误:Zend \ Mvc \ Controller \ Plugin \ Url类的对象不能转换为字符串 也许我对我的路线犯了一个错误,我将编辑我的帖子以添加我的代码 –
@ Reign.85我根据您的编辑修改了我的答案。希望这会给你想法如何创建网址:) –
坦克你这么多,这项工作对我来说,我只需要添加服务器的URL到路径 –