日本三级片在线观看视频_西西大胆午夜人体视频无码_少妇无码一区二区_亚洲天堂超碰_极品少妇被猛的白浆直流_91精品云霸高清中文字幕_草草五月天伊人_久久少妇无码专区_欧美激欧美啪啪5老太_日韩在线在线成人

thinkphp5獲取URL信息

2019-04-04 10:27:17 17883

如果要獲取當(dāng)前的請(qǐng)求信息,可以使用\think\Request類,

除了下文中的


$request = Request::instance();

也可以使用助手函數(shù)


$request = request();

當(dāng)然,最方便的還是使用注入請(qǐng)求對(duì)象的方式來獲取變量。


例如:


獲取URL信息

$request = Request::instance();

// 獲取當(dāng)前域名

echo 'domain: ' . $request->domain() . '<br/>';

// 獲取當(dāng)前入口文件

echo 'file: ' . $request->baseFile() . '<br/>';

// 獲取當(dāng)前URL地址 不含域名

echo 'url: ' . $request->url() . '<br/>';

// 獲取包含域名的完整URL地址

echo 'url with domain: ' . $request->url(true) . '<br/>';

// 獲取當(dāng)前URL地址 不含QUERY_STRING

echo '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/>';

輸出結(jié)果為:


domain: http://m.lncdfzh.com.cn

file: /index.php

url: /index/index/hello.html?name=thinkphp

url with domain: http://m.lncdfzh.com.cn/index/index/hello.html?name=thinkphp

url without query: /index/index/hello.html

root:root with domain: http://m.lncdfzh.com.cn

pathinfo: index/index/hello.html

pathinfo: index/index/hello

ext: html


提交成功!非常感謝您的反饋,我們會(huì)繼續(xù)努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問題: