Yii URL
2016-07-08 13:38
429 查看
参考文章:
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
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
相关文章推荐
- JHTP自测题_第八章_深入理解类和对象
- php网页游戏开发教程三(简单程序应用)
- php网页游戏开发教程二(游戏模式+系统)
- PHP创建的csv文件在windows上乱码的问题
- JHTP小结_第八章_深入理解类和对象
- php使用header设置浏览器缓存
- 对FlowLayoutPanel里面的控件进行排序
- 对laravel5概念的理解 -- 资源库模式(Repository)
- t4 multiple output sample
- 解决PHP里大量数据循环时内存耗尽的方法
- 顺丰BSP接口PHP开发注意事项
- PHP限制上传文件的大小(修改PHP.ini)
- 在ThinkPHP3.x框架中实现将原创文章第一时间推送到百度收录
- Unknown column '' in 'field list'解决方案
- php学生管理系统
- 【原创】Sublime Text 3设置吊炸天PHP开发环境
- 用花生棒+phpstudy建立个人博客的方法
- ThinkPHP的create方法的一系列操作
- Lnmp 支持thinkphp
- 开发自己PHP MVC框架