Yii URL
参考文章:
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的更多相关文章
- YIi url美化
一.Yii Url美化,配置urlManager组件 'urlManager' => [ 'enablePrettyUrl' => true, // 开启URL美化,可以去掉 index. ...
- yii url美化 urlManager组件
yii的官方文档对此的解释如下: urlSuffix 此规则使用的url后缀,默认使用CurlManger::urlSuffix,值为null.例如可以将此设置为.html,让url看起来“像”是一 ...
- Yii url createUrl redirect相关
一篇文章: 在yii中明明白白生成网址: 在Yii中经常要生成URL,不管是为了自动跳转还是仅仅是一个链接.下面对Yii中的URL生成做了一个总结.提示:以下controllerX代表控制器X,act ...
- IIS下 Yii Url重写
下载URL重写组件 http://www.microsoft.com/zh-cn/download/details.aspx?id=7435 导入官方提供的.htaccess文件 Options +F ...
- Javascript and AJAX with Yii(在yii 中使用 javascript 和ajax)
英文原文:http://www.yiiframework.com/wiki/394/javascript-and-ajax-with-yii /*** http://www.yiiframework. ...
- yii 常用一些调用 (增加中)
调用YII框架中 jquery:Yii::app()->clientScript->registerCoreScript('jquery'); framework/web/j ...
- yii获取当前url和域名
<?php //当前域名 echo Yii::app()->request->hostInfo; //除域名外的URL echo Yii::app()->request-> ...
- yii create url (二)
在Yii中经常要生成URL,不管是为了自动跳转还是仅仅是一个链接.下面对Yii中的URL生成做了一个总结.提示:以下controllerX代表控制器X,actionX代表方法X.在Controller ...
- yii create url (一)
1.$this->redirect这里的$this是当前的controller.可能是应用程序的也 可能是模块下的 这里仅将解一下第一个参能是url,当url是一个字符串时,它会自己动跳转 如$ ...
随机推荐
- 新手Oracle安装及使用入门
一.安装Oracle Step1 下载oracle压缩包并解压到同一文件夹下面 Step2 双击setup.exe进行安装 Step3:进入如下界面配置: 邮箱可不填,去掉更新 除了设置密码,其他均可 ...
- Hive 一些便捷小查询
show create table 表名; -- 可以查看表的DDL语句 describe 表名; -- 查看表的字段信息 explain dependency select count(1) fro ...
- Leetcode Find K Pairs with smallest sums
本题的特点在于两个list nums1和nums2都是已经排序好的.本题如果把所有的(i, j)组合都排序出来,再取其中最小的K个.其实靠后的很多组合根本用不到,所以效率较低,会导致算法超时.为了简便 ...
- 【poj1186】 方程的解数
http://poj.org/problem?id=1186 (题目链接) 题意 已知一个n元高次方程: 其中:x1, x2,…,xn是未知数,k1,k2,…,kn是系数,p1,p2,…pn是指数 ...
- JSP教程推荐
从搭建环境到上手JSP再到Servlet. http://www.runoob.com/jsp/jsp-tutorial.html
- C#制作验证码
void CodeImage(string code) { if (code == null || code.Trim() == string.Empty) return; System.Drawin ...
- EF-CodeFirst-3搞事
本文学习旺杰兄的 CodeFirst 系列教程而写.尽量摆脱之前的影子写出自己的理解 表间关系.级联删除 简单玩法已经走通了,但是我就是想搞点事出来.今天来搞搞表间关系和级联删除 表间关系 毫无疑问在 ...
- AngularJs $animate 让页面动起来
$animate $animate服务提供了基本的DOM操作功能如在DOM里插入.移除和移动元素,以及添加和删除类.这个服务是ngAnimate的核心服务,为CSS和Javascript提供了高档次的 ...
- HDU 1535 Invitation Cards(最短路 spfa)
题目链接: 传送门 Invitation Cards Time Limit: 5000MS Memory Limit: 32768 K Description In the age of te ...
- HDU 1166 敌兵布阵(线段树模板题)
题目链接: 传送门 敌兵布阵 Time Limit: 2000MS Memory Limit: 32768 K Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头 ...