zoukankan      html  css  js  c++  java
  • 6——ThinkPhp中的请求:

    <?php
    namespace appindexcontroller;
    use thinkconsoleInput;
    use thinkController;
    use thinkDb;
    use thinkRequest;
    
    class Index2 extends Controller
    {
        public function index($name="张三")
        {
           // return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ad_bd568ce7058a1091"></think>';
            $data=Db::name('users')->find();
            $this->assign('data',$data);
            $this->assign('name',$name); //assign:分派;选派
            return $this->fetch(); //fetch:抵达,到达
        }
        public function index2(){
            //获取当前的url:
            $request=Request::instance();
            echo 'request请求的url:'.$request->url().'<br/>';
    
            echo "this里面使用的request:".$this->request->url().'<br/>';
    
            //请求中绑定的数据:
            $this->request->bind('user_name','张三111');
            echo "绑定的数据内容:".$this->request->user_name.'<br/>';
    
            //请求的函数助手:
            echo request()->url()."<br/>";
    
            //获取请求信息:
            print_r(request()->param());
            echo "<br/>";
            echo '请求的参数name:'.request()->param('name');
    
            //获取请求信息的函数助手:
            print_r(input());
            echo input('name');
    
            //param支持变量的默认值和过滤:
            echo "<br/>";
            //请求中如果有name参数,就会取请求中的name参数,并转换为小写。如果没有就会取默认值,但不会进行小写转换:
            echo 
    equest()->param('name','XIAOWANG','strtolower');echo "<br/>";
    
            echo "==========================request======================";
            echo "<br/>";
            echo "GET请求参数:";
            print_r(
    equest()->get());
    
            echo "<br/>";
            echo "GET请求参数中的age值:";
            print_r(
    equest()->get('age'));
    
            echo "<br/>";
            echo "POST请求参数:";
            print_r(
    equest()->post());
            echo "<br/>";
            echo "POST请求的age值:";
            print_r(
    equest()->post('age'));
    
            echo "<br/>";
            echo "COOKIE值:";
            print_r(
    equest()->cookie());
            echo "<br/>";
            echo "FILE请求的值:";
            print_r(
    equest()->file());
    
            echo "==========================INPUT======================";
            echo "<br/>";
            echo "input请求参数:";
            print_r(input('get.'));
    
            echo "<br/>";
            echo "GET请求参数中的age值:";
            print_r(input('get.age'));
    
            echo "<br/>";
            echo "POST请求参数:";
            print_r(input('post.'));
            echo "<br/>";
            echo "POST请求的age值:";
            print_r(input('post.age'));;
    
            echo "<br/>";
            echo "COOKIE值:";
            print_r(input('cookie.'));
            echo "<br/>";
            echo "FILE请求的值:";
            print_r(input('file.'));
    
            echo "====================request其他参数========================";
            echo "<br/>";
            echo "请求方法:".
    equest()->method();
            echo "访问IP:".
    equest()->ip()."<br/>";
            echo "是否Ajax请求:".(
    equest()->isAjax()?"是":"否")."<br/>";
            echo "当前域名:".
    equest()->domain()."<br/>";
            echo "当前入口文件:".
    equest()->baseFile()."<br/>";
            echo "包含域名的完整URL地址:".
    equest()->url(true)."<br/>";
            echo "URL地址的参数信息:".
    equest()->query()."<br/>";
            echo "当前URL地址,不包含QUERY_STRING".
    equest()->baseUrl()."<br/>";
            echo "URL地址中的pathinfo信息:".
    equest()->pathinfo()."<br/>";
            echo "URL地址的后缀信息:".
    equest()->ext()."<br/>";
    
            echo "========================request当前模块/控制器/操作信息======================="."<br/>";
            echo "模块:".
    equest()->module()."<br/>";
            echo "控制器:".
    equest()->controller()."<br/>";
            echo "方法:".
    equest()->action();
        }
    }
    

      

  • 相关阅读:
    git 配置免密上传,配置ssh key
    spring @value 为什么没有获取到值
    idea 下maven 导入本地jar,以及导入之后 java不能引用问题
    在git远程仓创建项目之后,提交本地项目的使用方法
    mysql 查询数据库参数命令
    spring Existing transaction found for transaction marked with propagation 'never' 解决
    nginx for ubuntu
    spring中for循环中事务
    面向接口编程详解(一)——思想基础
    实战MEF(5):导出元数据
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/8849091.html
Copyright © 2011-2022 走看看