bapi Posted July 5, 2007 Share Posted July 5, 2007 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 More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 echo $test; where did you initialize the test Link to comment https://forums.phpfreaks.com/topic/58500-pls-me-to-fix-error-class/#findComment-290168 Share on other sites More sharing options...
bapi Posted July 5, 2007 Author Share Posted July 5, 2007 echo $test; where did you initialize the test $test is undefined variable, to create error Link to comment https://forums.phpfreaks.com/topic/58500-pls-me-to-fix-error-class/#findComment-290330 Share on other sites More sharing options...
RichardRotterdam Posted July 5, 2007 Share Posted July 5, 2007 Uhm hmmmm, The problem is echo $test; why just not remove it then so you dont have the error. Or do you want echo $test; to do something with the class? Link to comment https://forums.phpfreaks.com/topic/58500-pls-me-to-fix-error-class/#findComment-290336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.