PHP 中TP5 Request 請求對象的實(shí)例詳解
PHP 中TP5 Request 請求對象
public/index.php
<?php // [ 應(yīng)用入口文件 ] // 定義應(yīng)用目錄 define('APP_PATH', __DIR__ . '/../app/'); // 定義配置文件目錄和應(yīng)用目錄同級 define('CONF_PATH', __DIR__.'/../config/'); // 加載框架引導(dǎo)文件 require __DIR__ . '/../thinkphp/start.php';
app\index\controller\Index.php
<?php namespace app\index\controller; use think\Request; class Index { public function index(Request $request) { # 獲取瀏覽器輸入框的值 dump($request->domain()); dump($request->pathinfo()); dump($request->path()); # 請求類型 dump($request->method()); dump($request->isGet()); dump($request->isPost()); dump($request->isAjax()); # 請求的參數(shù) dump($request->get()); dump($request->param()); dump($request->post()); //session('name', 'onestopweb'); //cookie('email', 'onestopweb@163.com'); //session(null); //cookie('email',null); dump($request->session()); dump($request->cookie()); dump($request->param('type')); dump($request->cookie('email')); # 獲取模塊 控制器 操作 dump($request->module()); dump($request->controller()); dump($request->action()); # 獲取URL dump($request->url()); dump($request->baseUrl()); } }
地址欄輸入的鏈接:http://192.168.0.180:55/index/index/index.html?name=chaoyi&type=blog
string(23) "http://192.168.0.180:55" string(22) "index/index/index.html" string(17) "index/index/index" string(3) "GET" bool(true) bool(false) bool(false) array(2) { ["name"] => string(6) "chaoyi" ["type"] => string(4) "blog" } array(2) { ["name"] => string(6) "chaoyi" ["type"] => string(4) "blog" } array(0) { } array(1) { ["name"] => string(10) "onestopweb" } array(3) { ["username"] => string(6) "chaoyi" ["PHPSESSID"] => string(26) "nugcsr2j9krr2lhk8bntggl412" ["email"] => string(18) "onestopweb@163.com" } string(4) "blog" string(18) "onestopweb@163.com" string(5) "index" string(5) "Index" string(5) "index" string(45) "/index/index/index.html?name=chaoyi&type=blog" string(23) "/index/index/index.html"
以上就是PHP 中TP5 Request 請求對象的實(shí)例如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
在Laravel中實(shí)現(xiàn)使用AJAX動態(tài)刷新部分頁面
今天小編就為大家分享一篇在Laravel中實(shí)現(xiàn)使用AJAX動態(tài)刷新部分頁面,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10PHP制作3D扇形統(tǒng)計(jì)圖以及對圖片進(jìn)行縮放操作實(shí)例
這篇文章主要介紹了PHP制作3D扇形統(tǒng)計(jì)圖以及對圖片進(jìn)行縮放操作實(shí)例,需要的朋友可以參考下2014-10-10thinkPHP中create方法與令牌驗(yàn)證實(shí)例淺析
這篇文章主要介紹了thinkPHP中create方法與令牌驗(yàn)證,以一個簡單實(shí)例形式分析了thinkPHP中create方法與令牌驗(yàn)證增加表單安全性的相關(guān)技巧,代碼備有詳盡注釋說明,需要的朋友可以參考下2015-12-12destoon文章模塊調(diào)用企業(yè)會員資料的方法
這篇文章主要介紹了destoon文章模塊調(diào)用企業(yè)會員資料的方法,非常實(shí)用的一個技巧,需要的朋友可以參考下2014-08-08ThinkPHP采用<volist>實(shí)現(xiàn)三級循環(huán)代碼實(shí)例
這篇文章主要介紹了ThinkPHP采用<volist>實(shí)現(xiàn)三級循環(huán)代碼實(shí)例,通過實(shí)例加深讀者對<volist>標(biāo)簽用法的認(rèn)識,需要的朋友可以參考下2014-07-07