error display reporting php example - display run time errors

error display reporting php example - display run time errors

error-display-reporting-php-example.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>error display reporting php example - display run time errors</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="error display reporting php example - display run time errors">
  <meta name="keywords" content="php, example, code, array, function, error, display error, error_reporting">
  <meta name="description" content="error display reporting php example - display run time errors">
  <style>
   h2, h4{background:orange; color:#000086;}
   h2{ padding:3px; margin:3px; font-size:21px;}
   h4{ padding:2px; margin:2px; font-size:18px;}
   p{padding:2px; margin:2px; color:#0099FD;}
   body{ background:#FFFFFC;}
  </style>
 </head>
 <body>
  <h2>error display reporting php example - display run time errors</h2>
  <pre>
   <?php
    /*
     -------------------------------------------------------------------------------------
     let say we would like to check whether error display is on or off in this web server
     and we aslo want to check whether error reporting is enable or disable
     we can do check by using phpinfo() php function
     ------------------------------------------------------------------------------------------
    */
    
    //echo "<h4>error display reporting check for run time errors :</h4>";
    //echo phpinfo();
    
    /*
     -----------------------------------------------------
     now we would like to change error display and report
     we can do this by editting php.ini file like this :
     
     for displaying errors at run time : 
      error_reporting  =  E_ALL & ~E_NOTICE
      display_errors = On
      
     and for not displaying errors at run time : 
      error_reporting  =  E_NOTICE
      display_errors = Off
     
     -----------------------------------------------------
    */
    /*
     ----------------------------------------------------------------------------------------
     now we would like to make error display on and report error dynamically at the run time
     we can do this by editting php.ini file at run time
     ----------------------------------------------------------------------------------------
    */
    echo "<h4>error display and reporting at run time:</h4>";
    $errorDisplayReportOn = ini_set('error_reporting', E_ALL);
    // or error_reporting(1);
    // or error_reporting(E_ALL);
    // or ini_set('display_errors', TRUE);
    if($errorDisplayReportOn)
    {
     echo "<p>error display and reporting at run time success</p>";
    }
    else
    {
     echo "<p>error display and reporting at run time failure</p>";
    }
    /*
     -------------------------------------------------------------------------------------------
     now we would like to make error display off and report disable dynamically at the run time
     we can do this by editting php.ini file at run time
     -------------------------------------------------------------------------------------------
    */
    echo "<h4>error display off and reporting disable at run time:</h4>";
    $errorDisplayReportOff = ini_set('error_reporting', FALSE);
    // or error_reporting(0);
    // or error_reporting(E_NOTICE);
    // or ini_set('display_errors', FALSE);
    if($errorDisplayReportOff)
    {
     echo "<p>error display off and reporting disable at run time success</p>";
    }
    else
    {
     echo "<p>error display off and reporting disable at run time failure</p>";
    }
   ?>
  </pre>
 </body>
</html>

error display reporting php example - display run time errors - output in the browser

No comments:

Post a Comment

leave your comments here..