>  기사  >  백엔드 개발  >  PHP의 TP5 요청 요청 객체 방법

PHP의 TP5 요청 요청 객체 방법

墨辰丷
墨辰丷원래의
2018-05-18 17:09:442162검색

이 글은 PHP의 TP5 요청 객체의 세부 예시에 대한 관련 정보를 주로 소개하고 있으며, 이 부분의 내용 이해를 돕기 위해 구현 코드를 제공합니다.

TP5 요청 객체 PHP

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

주소창에 입력된 링크: http://192.168.0.180:55/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 요청 요청 개체의 예입니다. 질문이 있는 경우 메시지를 남기거나 이 사이트의 커뮤니티로 이동하여 토론하세요. 읽어주셔서 감사합니다. 모두에게 도움이 되기를 바랍니다.

관련 권장 사항:

Python 요청 라이브러리에서 양말5 프록시 인코딩 문제 해결

python3 요청에서 IP 프록시 풀을 사용하여 무작위로 IP를 생성하는 인스턴스

Python 요청의 프록시 인스턴스 기반 도서관

위 내용은 PHP의 TP5 요청 요청 객체 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.