时间:2021-07-01 10:21:17 帮助过:9人阅读
代码如下:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'
'
'
),
),
代码如下:
/**
* Normalizes the input parameter to be a valid URL.
*
* If the input parameter is an empty string, the currently requested URL will be returned.
*
* If the input parameter is a non-empty string, it is treated as a valid URL and will
* be returned without any change.
*
* If the input parameter is an array, it is treated as a controller route and a list of
* GET parameters, and the {@link CController::createUrl} method will be invoked to
* create a URL. In this case, the first array element refers to the controller route,
* and the rest key-value pairs refer to the additional GET parameters for the URL.
* For example, array('post/list', 'page'=>3)
may be used to generate the URL
* /index.php?r=post/list&page=3
.
*
* @param mixed $url the parameter to be used to generate a valid URL
* @return string the normalized URL
*/
public static function normalizeUrl($url)
{
if(is_array($url))
{
if(isset($url[0]))
{
if(($c=Yii::app()->getController())!==null)
$url=$c->createUrl($url[0],array_splice($url,1));
else
$url=Yii::app()->createUrl($url[0],array_splice($url,1));
}
else
$url='';
}
return $url==='' ? Yii::app()->getRequest()->getUrl() : $url;
}
以上就介绍了yii yii框架中的Url生产问题小结,包括了yii方面的内容,希望对PHP教程有兴趣的朋友有所帮助。