Anzeo Posted March 27, 2008 Share Posted March 27, 2008 Hi everyone, Im currently working on a site, making use of templates. Problem is, the PHP default error handler is not showing up anymore, which is kind of frustating (manually searching the files and such). Therefore I made my own handler as follows: function errorHandler($errorLevel, $errorMessage, $ErrorFile, $ErrorLine) { echo "<div class=\"error oranjeKaderNormaal\">Error [$errorLevel]: $errorMessage <br />op lijn $ErrorLine in $ErrorFile</div>"; die(); } //set error handler set_error_handler("errorHandler"); Problem is, it only shows correctly when I trigger an error manually, not when there are errors in the code. Does anyone know how to adjust this handler or another solution? Thanks in advance, Anzeo Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/ Share on other sites More sharing options...
trq Posted March 27, 2008 Share Posted March 27, 2008 Have you actually enabled errors in your php.ini and made sure that display errors is also on? You can do so in your code using... <?php error_reporting(E_ALL) ; ini_set('display_errors','1'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502157 Share on other sites More sharing options...
Anzeo Posted March 27, 2008 Author Share Posted March 27, 2008 I have, it made no diffrence. Could it be the templates causing troubles? Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502165 Share on other sites More sharing options...
Anzeo Posted March 27, 2008 Author Share Posted March 27, 2008 Anyone? I'm sorry, but I cannot properly continue without solving this. Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502398 Share on other sites More sharing options...
PFMaBiSmAd Posted March 27, 2008 Share Posted March 27, 2008 What exactly does this mean - the PHP default error handler is not showing up anymore You are likely getting a fatal parse error. Either check your web server log file or turn on full php error reporting in the master php.ini (assuming you have access to it), a .htaccess file (assuming php is running as an Apache server module), or a local php.ini (assuming that php is running as a cgi wrapper.) Turning on or changing php error reporting in your script won't help with parse errors because the code is never executed so the display errors/error reporting won't ever get changed. Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502425 Share on other sites More sharing options...
Anzeo Posted March 27, 2008 Author Share Posted March 27, 2008 Err.. I'm not familiar with those terms you mentioned. I only have a basic knowledge of PHP, none concerning server issues. I guess your right about the parse errors. Logging is off and can't set it on (hosted server). Strange thing is: it used to give me error message (like parse errors, telling me something was missing on line #). But once I started to split up my page (Header / Page / Footer) It's not showing anymore :/ Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502631 Share on other sites More sharing options...
Anzeo Posted March 27, 2008 Author Share Posted March 27, 2008 Ok it ost certainly are parse errors. I receive error messages when trying to call an undefined variable or function. However parse errors aren't shown anymore, and they used to be... I think it has something to do with the use of templates, but I'm unsure how to solve this. Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502640 Share on other sites More sharing options...
john010117 Posted March 27, 2008 Share Posted March 27, 2008 <?php error_reporting(E_ALL); ?> at the top of every page. If you're using a custom error handler, use set_error_handler(function_name) Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502641 Share on other sites More sharing options...
PFMaBiSmAd Posted March 27, 2008 Share Posted March 27, 2008 It is highly likely that the server was updated and the the display_errors setting got turned off. If you are making major changes to your pages, you should be doing it on a local development computer. Then once your code works without any errors, put in onto a live server. You will save time because the editing/debugging will go much quicker and you will have control over the settings in php.ini. An undefined variable will produce a notice message. A parse error is different. thorpe already posted the two lines of code above in his post that are needed to turn on the display of fatal runtime, warning, and notice messages. If you are not getting any output it means you are getting a fatal parse error. In any case, if you are making substantial changes to your code, you should be doing it locally on a development computer and not on a host server. Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502648 Share on other sites More sharing options...
Anzeo Posted March 27, 2008 Author Share Posted March 27, 2008 Hmm ok, so it are fatals. Do I need anything special to use my PC as a development pc? Thanks so far! Quote Link to comment https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502658 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.