Get URL Information
$request = Request::instance ();Get current domain nameEcho' Domain: '. $request->domain ().' <br/> ';Get Current Portal FileEcho' File: '. $request->basefile ().' <br/> ';Get current URL address without domain nameEcho' URL: '. $request->url ().' <br/> ';Get the full URL address that contains the domain nameEcho' URL with domain: '. $request->url (true).' <br/> ';Get current URL address does not contain query_stringEcho' URL without query: '. $request->baseurl ().' <br/> ';Gets the root address of the URL accessEcho' Root: '. $request->root ().' <br/> '; //Get the root address of the URL access echo ' root with domain: '. $request->root (true). ' <br/> '; //Get the Path_info information in the URL address echo ' pathinfo: '. $request->pathinfo (). ' <br/> '; //Get the Path_info information in the URL address without the suffix echo ' pathinfo: '. $request->path (). ' <br/> '; //Get the suffix information in the URL address echo ' ext: '. $request->ext (). ' <br/> ';
The output is:
domain: http://tp5.comfile: /index.phpurl: /index/index/hello.html?name=thinkphpurl with domain: http://tp5.com/index/index/hello.html?name=thinkphpurl without query: /index/index/hello.htmlroot:root with domain: http://tp5.compathinfo: index/index/hello.htmlpathinfo: index/index/helloext: html
&NBSP;
thinkphp5.0 Get URL information