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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                “完成,好過完美。” -- 臉譜書文化之一 ##1.19.1 一覽表 變量名稱|是否啟動時自動注冊|是否必須|接口/類|作用說明 ---|---|---|---|--- loader|否|是|[PhalApi_Loader](http://www.phalapi.net/docs/classes/PhalApi_Loader.html)|自動加載:負責PEAR風格下類的自動加載,需要手動注冊,指定項目路徑 config|否|是|[PhalApi_Config](http://www.phalapi.net/docs/classes/PhalApi_Config.html)|配置:負責項目配置的讀取,需要手動注冊,指定存儲媒介,默認是[PhalApi_Config_File](http://www.phalapi.net/docs/classes/PhalApi_Config_File.html) logger|否|是|[PhalApi_Logger](http://www.phalapi.net/docs/classes/PhalApi_Logger.html)|日志紀錄:負責日志的寫入,需要手動注冊,指定日志級別和存儲媒介,默認是[PhalApi_Logger_File](http://www.phalapi.net/docs/classes/PhalApi_Logger_File.html) request|是|是|[PhalApi_Request](http://www.phalapi.net/docs/classes/PhalApi_Request.html)|接口參數請求:用于收集接口請求的參數 response|是|是|[PhalApi_Response](http://www.phalapi.net/docs/classes/PhalApi_Response.html)|結果響應:用于輸出返回給客戶端的結果,默認為[PhalApi_Response_Json](http://www.phalapi.net/docs/classes/PhalApi_Response_Json.html) notorm|否|推薦|[PhalApi_DB_NotORM](http://www.phalapi.net/docs/classes/PhalApi_DB_NotORM.html)|數據操作:基于NotORM的DB操作,需要手動注冊,指定數據庫配置 cache|否|推薦|[PhalApi_Cache](http://www.phalapi.net/docs/classes/PhalApi_Cache.html)|緩存:實現緩存讀寫,需要手動注冊,指定緩存 filter|否|推薦|[PhalApi_Filter](http://www.phalapi.net/docs/classes/PhalApi_Filter.html)|攔截器:實現簽名驗證、權限控制等操作 crypt|否|否|[PhalApi_Crypt](http://www.phalapi.net/docs/classes/PhalApi_Crypt.html)|對稱加密:實現對稱加密和解密,需要手動注冊 curl|否|否|[PhalApi_CUrl](http://www.phalapi.net/docs/classes/PhalApi_CUrl.html)|CURL請求類:通過curl實現的快捷方便的接口請求類,需要手動注冊 cookie|否|否|[PhalApi_Cookie](http://www.phalapi.net/docs/classes/PhalApi_Cookie.html)|COOKIE的操作 debug|否|否|boolean|應用級的調試開關,通常可從配置讀取,暫時框架未用到 _formatterArray|否|否|[PhalApi_Request_Formatter_Array](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Array.html)|數組格式化服務(系統內部使用) _formatterBoolean|否|否|[PhalApi_Request_Formatter_Boolean](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Boolean.html)|布爾值格式化服務(系統內部使用) _formatterCallable|否|否|[PhalApi_Request_Formatter_Callable](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Callable.html)|回調格式化服務(系統內部使用) _formatterDate|否|否|[PhalApi_Request_Formatter_Date](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Date.html)|日期格式化服務(系統內部使用) _formatterEnum|否|否|[PhalApi_Request_Formatter_Enum](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Enum.html)|枚舉格式化服務(系統內部使用) _formatterFile|否|否|[PhalApi_Request_Formatter_File](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_File.html)|上傳文件格式化服務(系統內部使用) _formatterFloat|否|否|[PhalApi_Request_Formatter_Float](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Float.html)|浮點數格式化服務(系統內部使用) _formatterInt|否|否|[PhalApi_Request_Formatter_Int](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_Int.html)|整數格式化服務(系統內部使用) _formatterString|否|否|[PhalApi_Request_Formatter_String](http://www.phalapi.net/docs/classes/PhalApi_Request_Formatter_String.html)|字符串格式化服務(系統內部使用) ##1.19.2 DI服務是否已注冊的判斷誤區 ###(1)錯誤的判斷方法 當需要判斷一個DI服務是否已被注冊,出于常識會這樣判斷: ``` if (isset(DI()->cache)) { ``` 但這樣的判斷永遠為false,不管注冊與否。 追其原因在于,DI類使用了魔法方法的方式來提供類成員屬性,并存放于PhalApi_DI::$data中。 這就導致了如果直接使用isset(DI()->cache)的話,首先不會觸發魔法方法 PhalApi_DI::__get($name)的調用,其次也確實沒有PhalApi_DI::$cache這個成員屬性,最終判斷是否存在時都為false。 簡單來說,以下兩種判斷,永遠都為false: ``` //永遠為false var_dump(isset(DI()->XXX)); var_dump(!empty(DI()->XXX)); ``` ###(2)正確判斷的寫法:先獲取,再判斷 正確的用法應該是: ``` //先獲取,再判斷 $XXX = DI()->XXX; var_dump(isset($XXX)); var_dump(!empty($XXX)); ``` 這里,可能會對大家帶來一定的困惑,所以在這里特別進行說明。也對框架中這一點不合理的設計深感抱歉。
                  <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>

                              哎呀哎呀视频在线观看