参考文章:

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. Asp.net Mvc 使用EF6 code first 方式连接MySQL总结

    最近由于服务器变更为Linux系统.MsSql for Linux什么时候出来到生产环境使用还是要很长时间的.于是考虑使用Mysql数据库,ORM使用EF.于是先踩下坑顺便记录一下,有需要的tx可以参 ...

  2. python 基础 基本数据类型

    基本类型的补充 str --> 一次性创建的,不能被修改,强制修改就会在创建一个而之前的也会在 list -->允许重复的集合 修改  记录 链表,下一个元素的位置,上一个元素的位置 tu ...

  3. Linux学习路线

    为什么要学习Linux? 为什么学Linux,每个人都有自己的理由: Linux是免费的不用花一分钱,能够节约大笔的成本: Linux是开源的,你可以根据自已的需要修改源代码: Linux是开放的,有 ...

  4. POJ3468 A Simple Problem with Integers

    Description 给出了一个序列,你需要处理如下两种询问. "C abc"表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000). "Q  ...

  5. IAR使用记录

    1. Project-->Options... 更改器件:General-->Target-->Device 添加其它需包含的目录:C/C++ Compiler-->Prepr ...

  6. 基本概率分布Basic Concept of Probability Distributions 3: Geometric Distribution

    PDF version PMF Suppose that independent trials, each having a probability $p$, $0 < p < 1$, o ...

  7. 屠蛟之路_蛟灵岛战役(上)_SixthDay

    乘风破浪,屠蛟少年们终于到达beta怪蛟大boss的老巢--蛟灵岛. 这是一座孤立在东海深处的荒岛,岛上黑烟缭绕.瘴气重重,屠蛟少年们一登岛,就感受到浓浓的腥味和妖气. 果然,再小心翼翼,走两步居然陷 ...

  8. 软件工程个人作业 - week1

    <构建之法>阅读疑惑: 如何寻找开发效率和性能的均衡点?显然开发效率强调封装,重视代码重用.但是遗憾的是代码重用往往泛化了数据特征,降低了效率. 如何“公平”分配工作?尤其是团队中人员参差 ...

  9. Mysql学习笔记(五)数据查询之测试sql部分。

    正文之前,介绍mysql一些很有趣的命令. 快速的创建表,并填充表数据. create table test like  已经有的表名: inset into test select * from f ...

  10. iOS - CAEmitterLayer 学习笔记一

    其他参考博客: http://my.oschina.net/u/2340880/blog/485095 http://www.cnblogs.com/YouXianMing/p/3785876.htm ...