PHP 中TP5 Request的請求對象

不言
發布: 2023-03-30 20:16:02
原創
2015 人瀏覽過

這篇文章主要介紹了PHP 中TP5 Request 請求對象的實例詳解的相關資料,這裡提供實現代碼幫助大家理解這部分內容,需要的朋友可以參考下

PHP 中TP5 Request 請求物件

public/index.php

<?php 
 
// [ 应用入口文件 ] 
// 定义应用目录 
define(&#39;APP_PATH&#39;, __DIR__ . &#39;/../app/&#39;); 
 
// 定义配置文件目录和应用目录同级 
define(&#39;CONF_PATH&#39;, __DIR__.&#39;/../config/&#39;); 
 
// 加载框架引导文件 
require __DIR__ . &#39;/../thinkphp/start.php&#39;;
登入後複製

 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()); 
     
    # 请求的参数 
    dump($request->get()); 
    dump($request->param()); 
    dump($request->post()); 
    //session(&#39;name&#39;, &#39;onestopweb&#39;); 
    //cookie(&#39;email&#39;, &#39;onestopweb@163.com&#39;); 
    //session(null); 
    //cookie(&#39;email&#39;,null); 
    dump($request->session()); 
    dump($request->cookie()); 
     
    dump($request->param(&#39;type&#39;)); 
    dump($request->cookie(&#39;email&#39;)); 
     
    # 获取模块 控制器 操作 
    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中文網!

相關推薦:

PHP的圖像辨識技術原理與實作

關於thinkPHP內建字串截取函數的方法

#

以上是PHP 中TP5 Request的請求對象的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!