cbassett01 Posted June 30, 2011 Share Posted June 30, 2011 Is there a way that I can create some sort of custom PHP error handling script that is capable of looking at an error that occured and deciding what to do next or what to display to the user (rather than just printing out an error statement)? I'd ideally like this error handler to be in it's own script file so that I can include it in all scripts where an error might possibly occur. Second, is there a way that you can implement error handling like in other languages such as Visual Basic or C++/C#? For now, I've just been doing something like this: ------- mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error()); -------- I'd like to find a way so that if the die() function has to be called because of an error, I can call something else (a function in another script file) and send it some sort of error code that the function would then resolve to a more informative error message the user can understand). Suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/240755-customized-php-error-handler-script/ Share on other sites More sharing options...
KevinM1 Posted June 30, 2011 Share Posted June 30, 2011 PHP has exceptions and try/catch blocks, if that's what you're looking for. http://php.net/manual/en/language.exceptions.php Quote Link to comment https://forums.phpfreaks.com/topic/240755-customized-php-error-handler-script/#findComment-1236625 Share on other sites More sharing options...
xyph Posted June 30, 2011 Share Posted June 30, 2011 Also, you can define your error handler http://php.net/manual/en/function.set-error-handler.php Quote Link to comment https://forums.phpfreaks.com/topic/240755-customized-php-error-handler-script/#findComment-1236630 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.