thinkphp5如何获取请求过来的网址

thinkphp5获取请求网址的方法:1、使用“\think\Request”类的“$request = Request::instance();”方法获取当前的url信息;2、通过自带的助手函数“$request->url()”获取包含域名的完整URL地址。

THINKPHP5获取当前页面URL信息

想要获取当前页面的url信息,可以借助thinkphp 自带的request 类来获取当前的url信息

使用\think\Request类

$request = Request::instance();登录后复制

$request = request();登录后复制

domain: https://luweipai.cnfile: /index.phpurl: /index/index/hello.html?name=luweipaiurl with domain: https://luweipai.cn/index/index/hello.html?name=luweipaiurl without query: /index/index/hello.htmlroot:root with domain: http://luweipai.cnpathinfo: index/index/hello.htmlpathinfo: index/index/helloext: html登录后复制