分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

thinkphp5.0 获取URL信息

发布时间:2023-09-06 01:57责任编辑:熊小新关键词:thinkphp

获取URL信息

$request = Request::instance();// 获取当前域名echo ‘domain: ‘ . $request->domain() . ‘<br/>‘;// 获取当前入口文件echo ‘file: ‘ . $request->baseFile() . ‘<br/>‘;// 获取当前URL地址 不含域名echo ‘url: ‘ . $request->url() . ‘<br/>‘;// 获取包含域名的完整URL地址echo ‘url with domain: ‘ . $request->url(true) . ‘<br/>‘;// 获取当前URL地址 不含QUERY_STRINGecho ‘url without query: ‘ . $request->baseUrl() . ‘<br/>‘;// 获取URL访问的ROOT地址echo ‘root:‘ . $request->root() . ‘<br/>‘;// 获取URL访问的ROOT地址echo ‘root with domain: ‘ . $request->root(true) . ‘<br/>‘;// 获取URL地址中的PATH_INFO信息echo ‘pathinfo: ‘ . $request->pathinfo() . ‘<br/>‘;// 获取URL地址中的PATH_INFO信息 不含后缀echo ‘pathinfo: ‘ . $request->path() . ‘<br/>‘;// 获取URL地址中的后缀信息echo ‘ext: ‘ . $request->ext() . ‘<br/>‘;


输出结果为:

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
 

thinkphp5.0 获取URL信息

原文地址:https://www.cnblogs.com/my2018/p/9128160.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved