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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 錯誤和異常 在編碼的時候,我們無時無刻會遇到錯誤和異常,所以我們需要處理這些錯誤。 php的錯誤類型有 - E_ERROR 致命的錯誤。會中斷程序的執行 - E_WARNING 警告。不會中斷程序 - E_NOTICE 通知,運行時通知。表示腳本遇到可能會表現為錯誤的情況 - E_PARSE 解析錯誤,一般是語法錯誤。 - E_STRICT PHP 對代碼的修改建議 - E_DEPRECATED 將會對在未來版本中可能無法正常工作的代碼給出警告 ### 錯誤 在開發模式中,我們一般需要打開**error_reporting** 設置為**E_ALL**。然后把**display_errors** 設置為on 如果需要記錄錯誤日志,則需要配置log_errors. 開發者可以 通過set_error_handle()自己接管錯誤。 ```php set_error_handle(function($errno,$errstr,$errfile,$errline){ }) /** * throw exceptions based on E_* error types */ set_error_handler(function ($err_severity, $err_msg, $err_file, $err_line, array $err_context) { // error was suppressed with the @-operator if (0 === error_reporting()) { return false;} switch($err_severity) { case E_ERROR: throw new ErrorException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_WARNING: throw new WarningException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_PARSE: throw new ParseException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_NOTICE: throw new NoticeException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_CORE_ERROR: throw new CoreErrorException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_CORE_WARNING: throw new CoreWarningException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_COMPILE_ERROR: throw new CompileErrorException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_COMPILE_WARNING: throw new CoreWarningException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_USER_ERROR: throw new UserErrorException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_USER_WARNING: throw new UserWarningException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_USER_NOTICE: throw new UserNoticeException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_STRICT: throw new StrictException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_RECOVERABLE_ERROR: throw new RecoverableErrorException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_DEPRECATED: throw new DeprecatedException ($err_msg, 0, $err_severity, $err_file, $err_line); case E_USER_DEPRECATED: throw new UserDeprecatedException ($err_msg, 0, $err_severity, $err_file, $err_line); } }); class WarningException extends ErrorException {} class ParseException extends ErrorException {} class NoticeException extends ErrorException {} class CoreErrorException extends ErrorException {} class CoreWarningException extends ErrorException {} class CompileErrorException extends ErrorException {} class CompileWarningException extends ErrorException {} class UserErrorException extends ErrorException {} class UserWarningException extends ErrorException {} class UserNoticeException extends ErrorException {} class StrictException extends ErrorException {} class RecoverableErrorException extends ErrorException {} class DeprecatedException extends ErrorException {} class UserDeprecatedException extends ErrorException {} ``` #### PHP7的錯誤處理 PHP 7 改變了大多數錯誤的報告方式。error可以通過exception異常進行捕獲到.不能通過try catch捕獲。但是可以通過注冊到set_exception_handle捕獲。 - Throwable - Error - Exception ```php try { // Code that may throw an Exception or Error. } catch (Throwable $t) { // Executed only in PHP 7, will not match in PHP 5 } catch (Exception $e) { // Executed only in PHP 5, will not be reached in PHP 7 } ``` ### 異常 捕獲異常可以通過try catch 語句 ```php try{ //異常的代碼 }catch (Exception $e){ //處理異常 }finally{ //最后執行的 } ```
                  <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>

                              哎呀哎呀视频在线观看