Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/98157-custom-error-handling/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502425
Share on other sites

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 :/

Link to comment
https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502631
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502640
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/98157-custom-error-handling/#findComment-502648
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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