Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2.     //using a boolean variable to check if the site's online or not
  3.     $isAlive=FALSE;
  4.        
  5.     ////////////////////////////////////////////////////////////////////////
  6.     //This function will handle all the errors//////////////////////////////
  7.     //that may occur in the site's functioning./////////////////////////////
  8.     //$errorNumber - shows the error's number///////////////////////////////
  9.     //$errorMessage - shows what message the error holds////////////////////
  10.     //$errorFile - shows what file's generating the error///////////////////
  11.     //$errorLine - shows what line in $errorFile's generating the error/////
  12.     //$errorVar - shows what variable in $errorLine's generating the error//
  13.     ////////////////////////////////////////////////////////////////////////
  14.     function errorHandler($errorNumber, $errorMessage, $errorFile, $errorLine, $errorVar)
  15.     {
  16.         global $isAlive;
  17.         //building the error message
  18.         $message="An error occured in script '$errorFile' on line $errorLine: $errorMessage\n";
  19.         $message.=print_r($errorVar, 1);
  20.         if($isAlive) {//we won't be showing the error
  21.             echo '<div class="error">A system error occured. We apologize for the trouble we caused you.';
  22.         } else {//we're showing the error
  23.             echo '<div class="error">' . $message . '</div><br />';
  24.         }
  25.     }
  26.    
  27.     set_error_handler('errorHandler');
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement