Zend Framework教程-Zend_Helpers-动作助手-Url

Url主要用于创建url;
public function simple($action, $controller = null, $module = null, array $params = null)
public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)
public function direct($action, $controller = null, $module = null, array $params = null)

 

<?php


class IndexController extends Zend_Controller_Action
{


    public function init()
    {
        /* Initialize action controller here */
    }


    public function indexAction()
    {
        //$urlParser = $this->_helper->getHelper('UrlParser'); 
		//var_dump($urlParser->parse('http://blog.csdn.net/mengxiangbaidu/article/details/7236249')); 
		
    	$url = $this->_helper->getHelper('Url');
    	
    	$action = 'actionname';
    	$controller = 'controllername';
    	$module = 'modulename';
    	$params = array('param1'=>'中文参数');
    	var_dump($url->simple($action, $controller, $module, $params));
    	
    	$urlOptions = array(
    			'action'=>$action,
    			'controller'=>$controller,
    			'module'=>$module,
    			'params'=>$params);
    	var_dump($url->url($urlOptions));
    	var_dump($url->direct($action, $controller, $module, $params));
    	 
    	exit;
    }
}


 



www.localzend.com/helper_demo1/public/index


string(101) "/helper_demo1/public/modulename/controllername/actionname/param1/%E4%B8%AD%E6%96%87%E5%8F%82%E6%95%B0"
string(101) "/helper_demo1/public/modulename/controllername/actionname/params/%E4%B8%AD%E6%96%87%E5%8F%82%E6%95%B0"
string(101) "/helper_demo1/public/modulename/controllername/actionname/param1/%E4%B8%AD%E6%96%87%E5%8F%82%E6%95%B0"

你可能感兴趣的:(Zend Framework教程-Zend_Helpers-动作助手-Url)