新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
thinkphp5獲取當(dāng)前頁面URL信息
想要獲取當(dāng)前頁面的url信息,可以借助thinkphp 自帶的request 類來獲取當(dāng)前的url信息

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比蘇家屯網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式蘇家屯網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋蘇家屯地區(qū)。費(fèi)用合理售后完善,10多年實(shí)體公司更值得信賴。
使用\think\Request類
$request = Request::instance();
或者使用自帶的助手函數(shù)
$request = request();
$request = Request::instance();
// 獲取當(dāng)前域名
echo 'domain: ' . $request->domain() . '
';
// 獲取當(dāng)前入口文件
echo 'file: ' . $request->baseFile() . '
';
// 獲取當(dāng)前URL地址 不含域名
echo 'url: ' . $request->url() . '
';
// 獲取包含域名的完整URL地址
echo 'url with domain: ' . $request->url(true) . '
';
// 獲取當(dāng)前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() . '
';
輸出結(jié)果
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 網(wǎng)頁標(biāo)題:thinkphp5獲取當(dāng)前頁面URL信息
URL分享:http://m.fisionsoft.com.cn/article/cdepgie.html


咨詢
建站咨詢
