2014年12月19日 星期五

CodeIgniter 顯示錯誤訊息

1. 直接在php程式內寫入
ini_set('display_errors', 1);
2.設定index.php

define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/

if (defined('ENVIRONMENT'))
{
   switch (ENVIRONMENT)
   {
      case 'development':
        /* Report all errors */
        error_reporting(E_ALL);

        /* Display errors in output */
        ini_set('display_errors', 1);
      break;

      case 'testing':
      case 'production':
        /* Report all errors except E_NOTICE */
        /* This is the default value set in php.ini */
        error_reporting(E_ALL ^ E_NOTICE);

        /* Don't display errors (they can still be logged) */
        ini_set('display_errors', 0);
      break;

      default:
          exit('The application environment is not set correctly.');
    }
 }
參考資料
http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors

沒有留言:

張貼留言