php request render,Request 获取参数

Request 获取参数<?php

namespace app\index\controller;

//use think\Controller;

use think\Request;

class Index /*extends Controller*/

{

public function index($id,$name)

{

return '$id='.$id.',$name='.$name;

}

public function demo($id='',$name='')

{

$request = Request::instance();

dump($request->param('na'));

}

}

获取各项操作/参数<?php

namespace app\index\controller;

//use think\Controller;

use think\Request;

class Index /*extends Controller*/

{

public function index($id,$name)

{

return '$id='.$id.',$name='.$name;

}

public function demo($id='',$name='',$age='')

{

$request = Request::instance();

dump($request->domain());    //获取域名

dump($request->url());       //不包含域名

dump($request->url(true));   //包含域名

dump($request->pathinfo());  //包含后缀 .html

dump($request->path());      //不包含后缀

dump($request->ext());       //返回后缀  .html

dump($request->module());    //模块

dump($request->controller());//返回控制器

//        $request->action('text');    //更改操作

dump($request->action());    //获取错做方法

dump($request->method());    //获取请求类型

dump($request->ip());        //获取IP

dump($request->only('id'));   //只获取ID

dump($request->except('id')); //除了ID

}

}

返回结果:string(18) "http://www.tp5.com"

string(39) "/index/index/demo/id/12/name/luo/age/22"

string(57) "http://www.tp5.com/index/index/demo/id/12/name/luo/age/22"

string(38) "index/index/demo/id/12/name/luo/age/22"

string(38) "index/index/demo/id/12/name/luo/age/22"

string(0) ""

string(5) "index"

string(5) "Index"

string(4) "demo"

string(3) "GET"

string(9) "127.0.0.1"

array(1) {

["id"] => string(2) "12"

}

array(2) {

["name"] => string(3) "luo"

["age"] => string(2) "22"

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值