0
class Zend_View_Helper_Url extends Zend_View_Helper_Abstract {
    /**
     * Generates an url given the name of a route.
     *
     * @access public
     *
     * @param  array $urlOptions Options passed to the assemble method of the Route object.
     * @param  mixed $name The name of a Route to use. If null it will use the current Route
     * @param  bool $reset Whether or not to reset the route defaults with those provided
     * @return string Url for the link href attribute.
     */
    public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();
        return $router->assemble($urlOptions, $name, $reset, $encode);
    } }

以上代码来自zend/view/helper/url.php。

问题:

在评论中,它是根据路由名称生成一个 url,zend 框架中的路由是什么?以下代码来自:index.phtml

<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'edit', 'id'=>$album->id));?>">Edit</a>

那么你能解释一下 url() 方法在这里是如何工作的吗?

4

1 回答 1

0

Zend 有这样的 url 结构:

主机名/控制器/动作/参数

对于本地主机

本地主机/索引/索引/用户名/pramod

在哪里

Host- localhost
Controller - indexController
Action - index action in the indexcontroller
Parameter - username 
于 2013-04-25T04:53:21.690 回答