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 > Article > PHP Framework > 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!