request->hostInfo;" to get the current domain name, you can use the command "\Yii::$app->request->getUrl(); "Get the url except the domain name."/> request->hostInfo;" to get the current domain name, you can use the command "\Yii::$app->request->getUrl(); "Get the url except the domain name.">

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

How to get the current url in yii framework

尚
Original
2019-12-07 16:08:552269browse

How to get the current url in yii framework

1. Get the current domain name:

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

2. Get the url except the domain name:

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

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

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

4. Get the parameter part in the url:

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

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

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

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

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

(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!

Statement:
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