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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 創建附屬類 有些時候,你可能想在你的控制器之外新建一些類,但同時又希望 這些類還能訪問 CodeIgniter 的資源。下面你會看到,這其實很簡單。 **get_instance**() 返回: Reference to your controller's instance 返回類型: CI_Controller 任何在你的控制器方法中初始化的類都可以簡單的通過 get_instance() 函數來訪問 CodeIgniter 資源。這個函數返回一個 CodeIgniter 對象。 通常來說,調用 CodeIgniter 的方法需要使用 $this ~~~ $this->load->helper('url'); $this->load->library('session'); $this->config->item('base_url'); // etc. ~~~ 但是 $this 只能在你的控制器、模型或視圖中使用,如果你想在 你自己的類中使用 CodeIgniter 類,你可以像下面這樣做: 首先,將 CodeIgniter 對象賦值給一個變量: ~~~ $CI =& get_instance(); ~~~ 一旦你把 CodeIgniter 對象賦值給一個變量之后,你就可以使用這個變量 來 代替 $this ~~~ $CI =& get_instance(); $CI->load->helper('url'); $CI->load->library('session'); $CI->config->item('base_url'); // etc. ~~~ 如果你在類中使用``get_instance()`` 函數,最好的方法是將它賦值給 一個屬性 ,這樣你就不用在每個方法里都調用 get_instance() 了。 例如: ~~~ class Example { protected $CI; // We'll use a constructor, as you can't directly call a function // from a property definition. public function __construct() { // Assign the CodeIgniter super-object $this->CI =& get_instance(); } public function foo() { $this->CI->load->helper('url'); redirect(); } public function bar() { $this->CI->config->item('base_url'); } } ~~~ 在上面的例子中, foo() 和 bar() 方法在初始化 Example 類之后都可以正常工作,而不需要在每個方法里都調用 get_instance() 函數。
                  <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>

                              哎呀哎呀视频在线观看