掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流
想要獲取當前頁面的url信息,可以借助thinkphp 自帶的request 類來獲取當前的url信息

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比蘇家屯網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式蘇家屯網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋蘇家屯地區(qū)。費用合理售后完善,10多年實體公司更值得信賴。
使用\think\Request類
$request = Request::instance();
或者使用自帶的助手函數(shù)
$request = request();
$request = Request::instance();
// 獲取當前域名
echo 'domain: ' . $request->domain() . '
';
// 獲取當前入口文件
echo 'file: ' . $request->baseFile() . '
';
// 獲取當前URL地址 不含域名
echo 'url: ' . $request->url() . '
';
// 獲取包含域名的完整URL地址
echo 'url with domain: ' . $request->url(true) . '
';
// 獲取當前URL地址 不含QUERY_STRING
echo 'url without query: ' . $request->baseUrl() . '
';
// 獲取URL訪問的ROOT地址
echo 'root:' . $request->root() . '
';
// 獲取URL訪問的ROOT地址
echo 'root with domain: ' . $request->root(true) . '
';
// 獲取URL地址中的PATH_INFO信息
echo 'pathinfo: ' . $request->pathinfo() . '
';
// 獲取URL地址中的PATH_INFO信息 不含后綴
echo 'pathinfo: ' . $request->path() . '
';
// 獲取URL地址中的后綴信息
echo 'ext: ' . $request->ext() . '
';
輸出結果
domain: https://luweipai.cn
file: /index.php
url: /index/index/hello.html?name=luweipai
url with domain: https://luweipai.cn/index/index/hello.html?name=luweipai
url without query: /index/index/hello.html
root:
root with domain: http://luweipai.cn
pathinfo: index/index/hello.html
pathinfo: index/index/hello
ext: html 
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流