Jump to content

error reporting


SirChick

Recommended Posts

I am creating an advanced error reporting system for handy de-bugging with errors to do with logic for the most part.

 

What i got is this sort of idea say the main script had at certain parts of the script:

 

Mainfile.php:

44: <?php
45:
46: include("errorcoresystecheck.php");
47: //code stuff
48: include("errorcoresystecheck.php");
49: //code stuff
50: include("errorcoresystecheck.php");
51: ?>

 

 

 

What i want to do is say an error happens in the error system checker.... this would spell big problems so im putting error logging on the error checking system. So what i wanted to do was say the error occurred on the 2nd of those 3 includes...

firstly i can get what script it happened on which is mainfile.php using dirname(strtolower($_SERVER['PHP_SELF'])).

 

But is it physically possible to also get what line the user is on when this "insert" is taking place on the PHP_SELF page not the include file..so in this case it would show mainfile.php on line 48. as a log?

 

Link to comment
https://forums.phpfreaks.com/topic/95279-error-reporting/
Share on other sites

You can also do this, which is a bit less sophisticated, but still...

<?php
set_error_handler("my_error_handler");

function my_error_handler($errno,$errMsg,$errFile,$errLine,$errContext)
{
   echo "$errMsg occured in $errFile on line $errLine<br>";
}
trigger_error("this is a warning",E_USER_WARNING);
trigger_error("this is a total error",E_USER_ERROR);
?>

Link to comment
https://forums.phpfreaks.com/topic/95279-error-reporting/#findComment-488061
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.