PHP 中TP5 Request 請求對象的方法

來源:互聯網
上載者:User
這篇文章主要介紹了PHP 中TP5 Request 請求對象的執行個體詳解的相關資料,這裡提供實現代碼協助大家理解這部分內容,需要的朋友可以參考下

PHP 中TP5 Request 請求對象

public/index.php

<?php  // [ 應用入口檔案 ] // 定義應用目錄 define('APP_PATH', __DIR__ . '/../app/');  // 定義設定檔目錄和應用目錄同級 define('CONF_PATH', __DIR__.'/../config/');  // 載入架構引導檔案 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());          # 請求的參數     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 請求對象的執行個體如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能協助到大家!

相關推薦:

解決Python requests庫編碼 socks5代理的問題

python3 requests中使用ip代理池隨機產生ip的執行個體

基於python requests庫中的代理執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.