Request请求对象

 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.107/index/index/index.html?name=mingjun&type=blog

string(23) "http://192.168.0.107"
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) "mingjun"
 ["type"] => string(4) "blog"
} 
array(2) { 
 ["name"] => string(6) "mingjun"
 ["type"] => string(4) "blog"
} 
array(0) { 
} 
array(1) { 
 ["name"] => string(10) "onestopweb"
} 
array(3) { 
 ["username"] => string(6) "mingjun"
 ["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=mingjun&type=blog"
string(23) "/index/index/index.html"

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值