参考文章:

http://blog.csdn.net/iefreer/article/details/21325371

以http://localhost/basic/web/index.php?r=article/index为例

echo \yii\helpers\Url::base();

//输出/basic/web

echo \yii\helpers\Url::base(true)

//输出http://localhost/basic/web

//home是输出首页,加上true是输出加域名的首页

echo \yii\helpers\Url::home();

//输出/basic/web/index.php

echo\yii\helpers\Url::home(true);

//输出http:://localhost/basic/web/index.php

//当前的Url

echo \yii\helpers\Url::current();

//输出/basic/web/index.php?r=article/index

//to和toRoute都是生成Url,后面加true都是生成带域名的Url

echo \yii\helpers\Url::to([‘article/add’]);

//输出/basic/web/index.php?r=article/add

echo \yii\helpers\Url::to([‘article/edit’,’id’=>1]);

//输出/basic/web/index.php?r=article/add&id=1

echo \yii\helpers\Url::to([‘article/add’],true);

//输出http://localhost/basic/web/index.php?r=article/add

echo \yii\helpers\Url::to([‘article/edit’,’id’=>1],true);

//输出http://localhost/basic/web/index.php?r=article/add&id=1

echo\yii\helpers\Url::toRoute([‘article/add’]);

//输出/basic/web/index.php?r=article/add

echo \yii\helpers\Url::toRoute([‘article/edit’,’id’=>1]);

//输出/basic/web/index.php?r=article/add&id=1

echo \yii\helpers\Url::toRoute([‘article/add’],true);

//输出http://localhost/basic/web/index.php?r=article/add

echo\yii\helpers\Url::toRoute([‘article/edit’,’id’=>1],true);

//输出http://localhost/basic/web/index.php?r=article/add&id=1

//to和toRoute之间的区别,传入string时,to 会直接把string当成url和toRoute则会解析

echo\yii\helpers\Url::to(‘article/add’);

//输出article/add

echo\yii\helpers\Url::toRoute(‘article/add’);

//输出/basic/web/index.php?r=article/add

Yii URL的更多相关文章

  1. YIi url美化

    一.Yii Url美化,配置urlManager组件 'urlManager' => [ 'enablePrettyUrl' => true, // 开启URL美化,可以去掉 index. ...

  2. yii url美化 urlManager组件

    yii的官方文档对此的解释如下: urlSuffix  此规则使用的url后缀,默认使用CurlManger::urlSuffix,值为null.例如可以将此设置为.html,让url看起来“像”是一 ...

  3. Yii url createUrl redirect相关

    一篇文章: 在yii中明明白白生成网址: 在Yii中经常要生成URL,不管是为了自动跳转还是仅仅是一个链接.下面对Yii中的URL生成做了一个总结.提示:以下controllerX代表控制器X,act ...

  4. IIS下 Yii Url重写

    下载URL重写组件 http://www.microsoft.com/zh-cn/download/details.aspx?id=7435 导入官方提供的.htaccess文件 Options +F ...

  5. Javascript and AJAX with Yii(在yii 中使用 javascript 和ajax)

    英文原文:http://www.yiiframework.com/wiki/394/javascript-and-ajax-with-yii /*** http://www.yiiframework. ...

  6. yii 常用一些调用 (增加中)

    调用YII框架中 jquery:Yii::app()->clientScript->registerCoreScript('jquery');        framework/web/j ...

  7. yii获取当前url和域名

    <?php //当前域名 echo Yii::app()->request->hostInfo; //除域名外的URL echo Yii::app()->request-> ...

  8. yii create url (二)

    在Yii中经常要生成URL,不管是为了自动跳转还是仅仅是一个链接.下面对Yii中的URL生成做了一个总结.提示:以下controllerX代表控制器X,actionX代表方法X.在Controller ...

  9. yii create url (一)

    1.$this->redirect这里的$this是当前的controller.可能是应用程序的也 可能是模块下的 这里仅将解一下第一个参能是url,当url是一个字符串时,它会自己动跳转 如$ ...

随机推荐

  1. 如何才能恢复Excel文档的打开密码

    对于一些密码的破解,最常用的方法就是“暴力破解”,也是获取密码的最后一种方法,Advanced Office Password Recovery的暴力破解能够破解复杂的Office文档密码.wps也有 ...

  2. js学习笔记6----作用域及解析机制

    1.作用域: 域:空间.范围.区域… 作用:读.写 script  全局变量,全局函数 自上而下 函数 由里到外 {} 2.js解析: ⑴   “找一些东西”:var. function. 参数…… ...

  3. bzoj2653: middle

    首先,对于每个询问,我们二分答案 然后对于序列中大于等于中位数的数,我们把它们置为1,小于中位数的数,置为-1 那么如果一个区间和大于等于0,那么就资磁,否则就不滋磁 这个区间和呢,我们可以用主席树维 ...

  4. js-JavaScript高级程序设计学习笔记14

    第十六章 HTML5脚本编程 1.跨文档消息传递.简称XDM,指的是来自不同域的页面间传递消息. XDM的核心是postMessage()方法,接收两个参数,一条消息和消息接收方来自哪个域的字符串. ...

  5. 【poj3422】 Kaka's Matrix Travels

    http://poj.org/problem?id=3422 (题目链接) 题意 N*N的方格,每个格子中有一个数,寻找从(1,1)走到(N,N)的K条路径,使得取到的数的和最大. Solution ...

  6. CodeForces 51F Caterpillar

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  7. 雷赛dmc2410控制卡,驱动器 光栅 加电机

    一般驱动器为9pin接口:(1:VCC 2:限位近端 3:限位远端 4:GND):电源是供给限位器的 ,5:A+ 6:A- 7:B+ 8:B- 注意驱动器的电流大小和细分设置,电流一般1A左右 电流过 ...

  8. [IOS 实现TabBar在Push后的隐藏 以及 两级Tabbar的切换]

    翻了好多网页都没找到资料,自己试了下终于成功了,遂分享一下. 1.实现TabBar在Push后的隐藏 假如结构是这样 NavController->A->B,我们想要实现在A里有Tabba ...

  9. AspectJ获取方法注解的信息

    在使用Aspectj获取方法注解信息的时候,可以使用下面的代码片段: /** * Get value of annotated method parameter */ private <T ex ...

  10. django1.9 + uwsgi +nginx1.9 部署(centos6.6)

    django1.9 + uwsgi +nginx1.9 部署 官方介绍 https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_ngin ...