久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<small id='sJIgK'></small><noframes id='sJIgK'>

        <i id='sJIgK'><tr id='sJIgK'><dt id='sJIgK'><q id='sJIgK'><span id='sJIgK'><b id='sJIgK'><form id='sJIgK'><ins id='sJIgK'></ins><ul id='sJIgK'></ul><sub id='sJIgK'></sub></form><legend id='sJIgK'></legend><bdo id='sJIgK'><pre id='sJIgK'><center id='sJIgK'></center></pre></bdo></b><th id='sJIgK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sJIgK'><tfoot id='sJIgK'></tfoot><dl id='sJIgK'><fieldset id='sJIgK'></fieldset></dl></div>
        • <bdo id='sJIgK'></bdo><ul id='sJIgK'></ul>

      1. <legend id='sJIgK'><style id='sJIgK'><dir id='sJIgK'><q id='sJIgK'></q></dir></style></legend>

        <tfoot id='sJIgK'></tfoot>

        PHP 自定義錯誤頁面

        PHP custom error page(PHP 自定義錯誤頁面)

        <small id='i34fH'></small><noframes id='i34fH'>

      2. <tfoot id='i34fH'></tfoot>
          <tbody id='i34fH'></tbody>

            <legend id='i34fH'><style id='i34fH'><dir id='i34fH'><q id='i34fH'></q></dir></style></legend>
            • <bdo id='i34fH'></bdo><ul id='i34fH'></ul>
                • <i id='i34fH'><tr id='i34fH'><dt id='i34fH'><q id='i34fH'><span id='i34fH'><b id='i34fH'><form id='i34fH'><ins id='i34fH'></ins><ul id='i34fH'></ul><sub id='i34fH'></sub></form><legend id='i34fH'></legend><bdo id='i34fH'><pre id='i34fH'><center id='i34fH'></center></pre></bdo></b><th id='i34fH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='i34fH'><tfoot id='i34fH'></tfoot><dl id='i34fH'><fieldset id='i34fH'></fieldset></dl></div>
                  本文介紹了PHP 自定義錯誤頁面的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  每個人都說在活動站點中允許顯示錯誤"是不好的(由于一些安全問題).

                  Everyone says that "Enabling errors to be shown" in an active site is bad (due to some security issues).

                  現在,我們必須考慮兩種情況:

                  Now, we have to consider 2 cases:

                  1. 網站處于調試模式
                  2. 該站點未處于調試模式

                  現在,對于案例 #1:

                  我們想查看錯誤.怎么樣?

                  We want to see the errors. How?

                  ini_set('error_reporting', E_ALL);
                  ini_set('display_errors', 1);
                  

                  沒有比這更簡單的了.我們還可以為除 Parse 和 Fatal 之外的所有錯誤自定義錯誤處理程序.

                  Nothing more simple. Also we can customize an error handler for all errors except Parse and Fatal.

                  相反,如果情況是 #2:

                  我們希望能夠停用這些消息:

                  We would like to be able to deactivate the messages:

                  ini_set('error_reporting', 0);
                  ini_set('display_errors', 0);
                  

                  沒關系.但是如何向用戶顯示一條友好的消息,例如嘿,伙計,有些事情真的很糟糕.我不向您保證我們正在努力解決它,因為我們很懶惰.".您應該再次啟用錯誤并只使用函數 set_error_handler() 并希望不會發生解析或致命錯誤.但我的第一個問題是:

                  And it's ok. But what about showing users a friendly message such as "Hei man, something is really f**ked up. I don't assure you we are working to fix it, since we are very lazy.". You should enable errors again and just use the function set_error_handler() and hope that no parse or fatal errors occur. But my first question is:

                  問題 1:是否可以避免錯誤報告并在出現問題時加載自定義離線頁面?我的意思是,是否有可能有 ini_set('error_reporting', 0);ini_set('display_errors', 0); 并且仍然能夠告訴 PHP 加載自定義錯誤頁面?

                  Question 1: Is that possible to avoid error reporting and have a custom offline page that is loaded when something goes wrong? I mean, is it possible to have ini_set('error_reporting', 0); and ini_set('display_errors', 0); and still be able to tell PHP to load a custom Error page?

                  現在是另一個:

                  問題 2:我開發了一個類,利用 set_error_handler() 的強大功能將發生的錯誤記錄到數據庫中.通過這種方式,我可以跟蹤黑客嘗試和其他很酷的東西.(是的,我總是確定數據庫是可訪問的,因為如果我們無法連接到數據庫,我的應用程序就會關閉).這值得嗎?

                  Question 2: I developed a class that with the power of set_error_handler() logs errors occurred into the database. In this way I can keep track of hack attempts and other cool stuff. (And yes, i'm always sure the DB is accessible since my application shuts down if we cannot connect to the DB). Is this worth something?

                  推薦答案

                  前段時間我創建了一個小系統,當發生致命錯誤/拋出未捕獲的異常時,它會將您重定向到錯誤頁面.有可能假設每個請求都由一個文件處理并以該文件結尾,因此通過到達該文件的末尾,我確定一切正常.在這種情況下,我設置了在錯誤頁面上重定向的函數并將其注冊為關閉函數 - 因此它將在所有請求結束時調用.現在在這個函數中,我檢查干凈關閉的條件,如果滿足,我什么都不做,輸出被刷新到瀏覽器,否則緩沖區被清除,只發送重定向到錯誤頁面的標頭.

                  Some time ago I created small system that redirects you to error page when fatal error occurs / uncaught exception was thrown. It was possible with assumption, that every request is handled by one file and ends in this file, so by reaching end of this file I'm sure that everything went OK. With this condition I've set up function to redirect on error page and registered it as shutdown function - so it will be called at the end of all requests. Now in this function I check conditions for clean shutdown and if hey are met, I do nothing and output is flushed to the browser, otherwise buffer is cleaned and only header redirecting to error page is sent.

                  此代碼的簡化版本:

                  <?php
                  function redirect_on_error(){
                      if(!defined('EVERYTHING_WENT_OK')){
                          ob_end_clean();
                          header('Location: error.html');
                      }
                  }
                  
                  register_shutdown_function('redirect_on_error');
                  
                  ob_start();
                  
                  include 'some/working/code.php';
                  
                  echo "Now I'm going to call undefined function or throw something bad";
                  
                  undefined_function();
                  throw new Exception('In case undefined function is defined.');    
                  
                  define('EVERYTHING_WENT_OK', TRUE);
                  exit;
                  

                  這篇關于PHP 自定義錯誤頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                • <legend id='d6rgt'><style id='d6rgt'><dir id='d6rgt'><q id='d6rgt'></q></dir></style></legend>

                      <tbody id='d6rgt'></tbody>

                      1. <i id='d6rgt'><tr id='d6rgt'><dt id='d6rgt'><q id='d6rgt'><span id='d6rgt'><b id='d6rgt'><form id='d6rgt'><ins id='d6rgt'></ins><ul id='d6rgt'></ul><sub id='d6rgt'></sub></form><legend id='d6rgt'></legend><bdo id='d6rgt'><pre id='d6rgt'><center id='d6rgt'></center></pre></bdo></b><th id='d6rgt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='d6rgt'><tfoot id='d6rgt'></tfoot><dl id='d6rgt'><fieldset id='d6rgt'></fieldset></dl></div>
                        • <bdo id='d6rgt'></bdo><ul id='d6rgt'></ul>
                          1. <tfoot id='d6rgt'></tfoot>

                            <small id='d6rgt'></small><noframes id='d6rgt'>

                            主站蜘蛛池模板: 免费麻豆视频 | 久久久久久久91 | 一级毛片高清 | 久草.com| 美女视频一区二区三区 | 久久久久久久久久久久亚洲 | 亚洲成人一区二区在线 | 国产日韩一区二区 | 国产一区二区在线视频 | 国产精品一区久久久 | 国产精品美女久久久av超清 | 久视频在线观看 | 亚洲国产一区二区在线 | 日韩 欧美 综合 | 国产激情一区二区三区 | 国产精品乱码一区二区三区 | 日本一二区视频 | 亚洲狠狠丁香婷婷综合久久久 | 亚洲一区二区三区视频 | 日本人麻豆| 精品96久久久久久中文字幕无 | 91五月婷蜜桃综合 | 国产精品久久久久久久久久免费看 | 午夜国产精品视频 | 国产精品国产精品国产专区不卡 | 亚洲视频在线看 | 色桃网| 在线观看亚洲专区 | 999精品网| 日韩和的一区二在线 | 天天玩天天操天天干 | 欧美福利一区 | 精品免费国产视频 | 亚洲91av| 中文字幕 亚洲一区 | 日韩av一区二区在线观看 | 国产精品久久久久久久久久软件 | 91一区二区 | 国产在线成人 | 久久精品一 | 国产一级片免费视频 |