TP5 Request 请求对象
程序员文章站
2022-04-25 17:40:39
...
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"
下一篇: day04【Map集合】
推荐阅读
-
python3发送request请求及查看返回结果实例
-
request(域对象)和response的区别和用法
-
Struts2实现对action请求对象的拦截操作方法
-
java web学习_浅谈request对象中get和post的差异
-
详解spring cloud hystrix请求缓存(request cache)
-
详解spring cloud hystrix请求缓存(request cache)
-
Servlet获取AJAX POST请求中参数以form data和request payload形式传输的方法
-
Zend Framework教程之请求对象的封装Zend_Controller_Request实例详解
-
详解Django中Request对象的相关用法
-
javascript asp教程第八课--request对象