Jump to content

Recommended Posts

Hi,

 

Pls. take a look on below script that i have created. It have some problem in it.

 

SCRIPT :

 

<?php

/*************************************************************************************************

    *

* Name : Errors class

* Purpose: This class Maintain all the error and display errors according to it

*

**************************************************************************************************/

 

class errorHandler  //*** Error Mgs class

{

 

/*------------------------------------------  MEATHODS  -----------------------------------------*/

 

function errorHandler() //*** Constructor meathod

{

$this->getError($errno, $errmsg, $filename, $linenum, $vars);

$this->set_error_handler("getError"); //set error handler

 

} //End ErrorMgs

 

/*------------------------------------------  MEATHODS  -----------------------------------------*/

 

function getError($errno, $errmsg, $filename, $linenum, $vars) // error handler

{

 

 

switch ($errno)

  {

      case 1 : //-- E_ERROR

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

    case 2 : //-- E_WARNING

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 4 : //-- E_PARSE

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 8 : //-- E_NOTICE

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 16: //-- E_CORE_ERROR

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 32: //-- E_CORE_WARING

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 64: //-- E_COMPILE_ERROR

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

      case 128: //-- E_COMPILE_WARNING

$this->E_NO = $errno;   // Error NO

$this->E_MGS = $errstr;      // Error MESSAGE

$this->E_LINENO = $errline; // Error LINE NO

$this->E_FILE  = $errfile; // Error FILE NAME

$this->E_CONTEXT = $errcontext; // Error CONTEXT

break;

 

} // End switch

 

// Log the error & Send an Notice to admin

$this->logError($params);

 

//Move to error pg

$this->displayError(); // Dusplay Error pg

 

}

 

 

/*------------------------------------------  MEATHODS  -----------------------------------------*/

 

function logError() // Log the errors into table

{

// Creating message

$date= date("Y-m-d H:i:s (T)");//date('l dS \of F Y h:i:s A');

 

error_log(" <b>Error:</b> ['$this->E_NO'] $this->E_MSG <br> ", 3, $_SERVER['DOCUMENT_ROOT']."/logerrors/logerrors.html");// Log into text file in server

}

 

/*------------------------------------------  MEATHODS  -----------------------------------------*/

 

function displayError() // Log the errors into table

{

header("Location: http://localhost/theam/error.php");  // On error

exit;

}

 

}//End Class

 

 

 

/*---------------------------------------------- END -------------------------------------*/

//---------------------- Test for class

 

$er = &new errorHandler();

 

echo $test;

 

?>

 

The out put of this is : " Error: [] "

 

I was to get someting like this :  " Error: [8]-[14] Undefined variable: test  "

 

 

So can anyone  say there is problem & help me to fix it.

 

I am use PHP4.X.X

Link to comment
https://forums.phpfreaks.com/topic/58500-pls-me-to-fix-error-class/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.