Home > PHP Framework > YII > How to get the current url in yii framework

How to get the current url in yii framework

Release: 2019-12-07 16:08:55
Original
2321 people have browsed it

How to get the current url in yii framework

1. Get the current domain name:

//当前域名 
\Yii::$app->request->hostInfo;
Copy after login

2. Get the url except the domain name:

//除域名外的URL 
\Yii::$app->request->getUrl();
Copy after login

3. Get the path information in the url ( Excluding host and parameters):

//获取url中的路径信息(不包含host和参数)
\Yii::$app->request->getPathInfo();
Copy after login

4. Get the parameter part in the url:

//获取url中的参数部分
\Yii::$app->getRequest()->queryString;
Copy after login

5. Get the value of a certain parameter, such as id:

//获取某个参数的值,比如id
\Yii::$app->getRequest()->get('id');
Copy after login

6 , Get the root directory address except the domain name:

//除域名外的根目录地址 
\Yii::$app->homeUrl;
Copy after login

(recommended learning: yii framework)

The above is the detailed content of How to get the current url in yii framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template