<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>

                ## 參數傳入 通過操作方法的參數綁定功能,可以實現自動獲取URL的參數,仍然以上面的控制器為例,控制器代碼如下: ~~~ <?php namespace app\index\controller; class Index { public function index() { return 'index'; } public function hello($name = 'World') { return 'Hello,' . $name . '!'; } } ~~~ 當我們訪問 ~~~ http://tp5.com/index.php/index/index/hello ~~~ 就是訪問`app\index\controller\Index`控制器類的`hello`方法,因為沒有傳入任何參數,`name`參數就使用默認值`World`。如果傳入name參數,則使用: ~~~ http://tp5.com/index.php/index/index/hello/name/thinkphp ~~~ 頁面輸出結果為: ~~~ Hello,thinkphp! ~~~ 現在給hello方法增加第二個參數: ~~~ public function hello($name = 'World', $city = '') { return 'Hello,' . $name . '! You come from ' . $city . '.'; } ~~~ 訪問地址為 ~~~ http://tp5.com/index.php/index/index/hello/name/thinkphp/city/shanghai ~~~ 頁面輸出結果為: ~~~ Hello,thinkphp! You come from shanghai. ~~~ 可以看到,`hello`方法會自動獲取URL地址中的同名參數值作為方法的參數值,而且這個參數的傳入順序不受URL參數順序的影響,例如下面的URL地址輸出的結果和上面是一樣的: ~~~ http://tp5.com/index.php/index/index/hello/city/shanghai/name/thinkphp ~~~ 或者使用 ~~~ http://tp5.com/index.php/index/index/hello?city=shanghai&name=thinkphp ~~~ 還可以進一步對URL地址做簡化,前提就是我們必須明確參數的順序代表的變量,我們更改下URL參數的獲取方式,把應用配置文件中的`url_param_type`參數的值修改如下: ~~~ // 按照參數順序獲取 'url_param_type' => 1, ~~~ 現在,URL的參數傳值方式就變成了嚴格按照操作方法的變量定義順序來傳值了,也就是說我們必須使用下面的URL地址訪問才能正確傳入`name`和`city`參數到`hello`方法: ~~~ http://tp5.com/index.php/index/index/hello/thinkphp/shanghai ~~~ 頁面輸出結果為: ~~~ Hello,thinkphp! You come from shanghai. ~~~ 如果改變參數順序為 ~~~ http://tp5.com/index.php/index/index/hello/shanghai/thinkphp ~~~ 頁面輸出結果為: ~~~ Hello,shanghai! You come from thinkphp. ~~~ 顯然不是我們預期的結果。 同樣,我們試圖通過 ~~~ http://tp5.com/index.php/index/index/hello/name/thinkphp/city/shanghai ~~~ 訪問也不會得到正確的結果。 >[danger]#### 注意 >**** >按順序綁定參數的話,操作方法的參數只能使用URL pathinfo變量,而不能使用get或者post變量。
                  <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>

                              哎呀哎呀视频在线观看