久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP錯誤處理函數(shù)

      PHP錯誤處理函數(shù)

      當(dāng)程序在線上運行時,如果遇到BUG,想不在前端輸出錯誤信息,同時能及時郵件通知開發(fā)者,register_shutdown_function函數(shù)就可以派上用場了。

      注冊一個會在腳本執(zhí)行完成或者 exit() 后被調(diào)用的函數(shù)。

      可以多次調(diào)用register_shutdown_function(),這些被注冊的回調(diào)會按照他們注冊時的順序被依次調(diào)用。 如果你在注冊的方法內(nèi)部調(diào)用 exit(), 那么所有處理會被中止,并且其他注冊的中止回調(diào)也不會再被調(diào)用。

      register_shutdown_function函數(shù),當(dāng)我們的腳本執(zhí)行完成或意外死掉導(dǎo)致PHP執(zhí)行即將關(guān)閉時,我們的這個函數(shù)將會 被調(diào)用,可以配合 error_get_last 使用,獲取錯誤信息。

      register_shutdown_function ( callable $callback [, mixed $parameter [, mixed $... ]] )

      callable 回調(diào)函數(shù)

      parameter可以通過傳入額外的參數(shù)來將參數(shù)傳給中止函數(shù)。

      DEMO1:

      //關(guān)閉錯誤報告 error_reporting(0); //實現(xiàn)自己的錯誤信息展示 register_shutdown_function(‘myShutdown‘); $debug = true; function myShutdown() {  global $debug;  // 無論錯誤是否發(fā)生,這句都會執(zhí)行  echo ‘ERROR‘ , ‘<br/>‘;  if (!$debug) {    $error = error_get_last();    // todo 可以在這里做郵件發(fā)送提醒 或 錯誤日志收集    var_export($error);  } }

      DEMO2:

      // 回到函數(shù)帶參數(shù):記錄當(dāng)前請求URL $current_page = htmlspecialchars($_SERVER[‘SCRIPT_NAME‘], ENT_QUOTES, ‘UTF-8‘); $current_page .= $_SERVER[‘QUERY_STRING‘] ? ‘?‘.htmlspecialchars($_SERVER[‘QUERY_STRING‘], ENT_QUOTES, ‘UTF-8‘) : ‘‘; register_shutdown_function(function ($current_page) {  //todo send email or log }, $current_page); error_get_last()  //錯誤信息查看:http://php.net/manual/zh/errorfunc.constants.php

      推薦教程:PHP視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號