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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                #### 控制器初始化 如果控制器下面的每個操作都需要執行一些公共的操作(例如權限和登錄檢查),有兩種方法,如果你沒有繼承系統的控制器基類,可以使用架構方法來進行初始化,例如: ~~~ <?php namespace app\index\controller; class Index { // 架構方法 public function __construct() { echo 'init<br/>'; } public function hello() { return 'hello,world'; } public function test() { return 'test'; } } ~~~ 如果已經繼承了系統控制器基類,那么可以使用控制器初始化方法: ~~~ <?php namespace app\index\controller; use think\Controller; class Index extends Controller { // 初始化 protected function _initialize() { echo 'init<br/>'; } public function hello() { return 'hello,world'; } public function test() { return 'test'; } } ~~~ 無論使用何種方式,當我們訪問下面的URL地址 ~~~ http://tp5.com/index/index/hello ~~~ 頁面輸出結果為: > init > hello,world 如果應用的所有控制器都需要執行一些公共操作,則只需要讓應用控制器都統一繼承一個公共的控制器類,然后在該公共控制器類里面定義初始化方法即可。 例如在公共Base控制器類里面定義初始化方法: ~~~ <?php namespace app\index\controller; use think\Controller; class Base extends Controller { // 初始化 protected function _initialize() { echo 'init<br/>'; } } ~~~ 然后其它控制器都繼承Base控制器類: ~~~ <?php namespace app\index\controller; use app\index\controller\Base; class Index extends Base { public function hello() { return 'hello,world'; } public function test() { return 'test'; } } ~~~ 初始化方法里面的`return操作`是無效的,也不能使用redirect助手函數進行重定向,如果你是要進行重定向操作(例如權限檢查后的跳轉)請使用`$this->redirect()`方法,參考后面的跳轉和重定向內容。不過,初始化方法中仍然支持拋出異常。
                  <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>

                              哎呀哎呀视频在线观看