您好,欢迎访问一九零五行业门户网

Yii2框架中如何获取URL的方法

1. 获取url中的host信息:
例如:
yii::$app->request->gethostinfo();
结果:
2. 获取url中的路径信息(不包含host和参数):
例如:
yii::$app->request->getpathinfo()
结果:product/2.html
3. 获取不包含host信息的url(含参数):
例如:
yii::$app->request->url
结果:product/2.html?isnew=1
4. 获取完整url(含host以及参数):
例如:
yii::$app->request->gethostinfo().yii::$app->request->url;
结果:
5.只想获取url中的参数部分:
例如:
yii::$app->request->querystring
结果:isnew=1
6.获取某个参数的值,比如id
例如:
yii::$app->request->getqueryparam('id')
结果:12345
以上就是yii2框架中如何获取url的方法的详细内容。
其它类似信息

推荐信息