Heim  >  Artikel  >  Backend-Entwicklung  >  Das Anforderungsobjekt von TP5 Request in PHP

Das Anforderungsobjekt von TP5 Request in PHP

不言
不言Original
2018-06-08 15:44:082010Durchsuche

In diesem Artikel werden hauptsächlich relevante Informationen zu den detaillierten Beispielen von TP5-Request-Anforderungsobjekten in PHP vorgestellt. Der Implementierungscode wird hier bereitgestellt, um allen zu helfen, diesen Teil des Inhalts zu verstehen.

PHP TP5 Request request object

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;;

appindexcontrollerIndex .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()); 
  } 
}

In der Adressleiste eingegebener Link: 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"

Das Obige ist der gesamte Inhalt dieses Artikels, der für das Studium aller nützlich sein wird Bitte achten Sie auf die chinesische PHP-Website!

Verwandte Empfehlungen:

Prinzipien und Implementierung der Bilderkennungstechnologie in PHP

Über die integrierte String-Interception-Funktionsmethode von thinkPHP

Das obige ist der detaillierte Inhalt vonDas Anforderungsobjekt von TP5 Request in PHP. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn