TP Request请求

2017年11月7日09:20:26 1 1,384 阅读

<?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());
}
}
以下是输出内容

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"

  • A+
所属分类:PHP
张晔璇

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  0   博主  1

    • avatar code Admin
      QQbrowser 9.7.12900.400 QQbrowser 9.7.12900.400 Windows 7 x64 Edition Windows 7 x64 Edition
      Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4549.400 QQBrowser/9.7.12900.400

      :twisted: :neutral: 模板测试