SirChick Posted March 9, 2008 Share Posted March 9, 2008 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? Quote Link to comment Share on other sites More sharing options...
SirChick Posted March 9, 2008 Author Share Posted March 9, 2008 no one =/ ? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 9, 2008 Share Posted March 9, 2008 i'd love to help, but honestly i don't know. -1 star for me. Quote Link to comment Share on other sites More sharing options...
SirChick Posted March 9, 2008 Author Share Posted March 9, 2008 lol... alot of people have said they don't know but it must be do-able if natural php syntax error's can say the line ... Quote Link to comment Share on other sites More sharing options...
KrisNz Posted March 9, 2008 Share Posted March 9, 2008 Use the built in Exception class. http://php.net/manual/en/language.exceptions.php Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 9, 2008 Share Posted March 9, 2008 wow, that's cool. much like Java and other languages i have played with. thanks for that tip! Quote Link to comment Share on other sites More sharing options...
SirChick Posted March 9, 2008 Author Share Posted March 9, 2008 nice one KrisNz!! Quote Link to comment Share on other sites More sharing options...
KrisNz Posted March 9, 2008 Share Posted March 9, 2008 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); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.