<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## 控制器中Request類的使用 我們先看一下TP5控制器的構造函數源碼 ~~~ /** * 構造方法 * @param Request $request Request對象 * @access public */ public function __construct(Request $request = null) { if (is_null($request)) { $request = Request::instance(); } $this->view = View::instance(Config::get('template'), Config::get('view_replace_str')); $this->request = $request; // 控制器初始化 $this->_initialize(); // 前置操作方法 if ($this->beforeActionList) { foreach ($this->beforeActionList as $method => $options) { is_numeric($method) ? $this->beforeAction($options) : $this->beforeAction($method, $options); } } } ~~~ 我們可以看出,在控制器類初始化時候注入了 Request 類,并將 Request 類賦值到 $this->request , > 完全開發手冊中也有提到,繼承系統控制器類可以直接調用 Request 類 OK,那我們就直接來看看 Request 類如果在控制器的使用 > 題外話我們要改掉使用助手函數的習慣,(包括我自己,以前的代碼中也是有些助手函數,我們一起改正吧),特別是 Request 類助手函數重復使用率非常高, 另:request類詳細說明請參見 完全開發手冊 http://www.hmoore.net/manual/thinkphp5/118042 那么,在控制器中然后快速獲取各類參數值呢? 我自己寫例子了 ~~~ //獲取所有get值 $this->request->get(); //獲取指定name名稱的get值 $this->request->get('name'); //獲取所有post值 $this->request->post(); //獲取指定name名稱的post值 $this->request->post('name'); //獲取所有參數值(get post都可以) $this->request->param(); //獲取指定name名稱的參數值(get post都可以) $this->request->param('name'); ~~~ > Request 類的值很多,可能常用的就是get post,其實用Request 類還可以獲取服務器變量 session cookie > 變量類型方法包括: > | 方法 | 描述 | > | --- | --- | > | param | 獲取當前請求的變量 | > | get | 獲取 $_GET 變量 | > | post | 獲取 $_POST 變量 | > | put | 獲取 PUT 變量 | > | delete | 獲取 DELETE 變量 | > | session | 獲取 $_SESSION 變量 | > | cookie | 獲取 $_COOKIE 變量 | > | request | 獲取 $_REQUEST 變量 | > | server | 獲取 $_SERVER 變量 | > | env | 獲取 $_ENV 變量 | > | route | 獲取 路由(包括PATHINFO) 變量 | > | file | 獲取 $_FILES 變量| 還有,我們也經常使用request類判斷 請求類型 ~~~ $this->request->isGet(); $this->request->isPost(); $this->request->isAjax(); ~~~ 更詳盡的參照完全開發手冊吧
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看