简体   繁体   中英

issue about url method in zend framework1

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);
    } }

Above code is from zend/view/helper/url.php.

Question:

in the comments, it is Generates an url given the name of a route, what is the route in zend framework? Below code is from: index.phtml

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

So could you explain how does url() method function here?

Zend have the url structure like this :

hostname/controller/action/parametes

for localhost

Localhost/index/index/username/pramod

where

Host- localhost
Controller - indexController
Action - index action in the indexcontroller
Parameter - username 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM