15

I've recently switched from WAMP/XAMPP to LAMP and one thing I found useful was the clean, formatted error reporting. On my current server it just displays errors as plain text, and it can be hard to read through using a web browser (and not viewing source). So is there any way to display errors similarly to WAMP, like in an HTML table with styling?

2 Answers 2

25

It's a PHP setting, not specific to any *AMP platform, set in php.ini:

html_errors = 1

relevant docs: http://www.php.net/manual/en/errorfunc.configuration.php#ini.html-errors

Sign up to request clarification or add additional context in comments.

2 Comments

u can also install xdebug to have coloring and more control over the format of your debug output. xdebug.org
This question/answer is heavily underrated.
6

In php.ini there are several settings that can be adjusted to create a readable result.

  1. display_errors = On - this one is not directly related to the question, but for obvious reasons I thought it should be included;
  2. html_errors = On - php engine will render the errors as a HTML page, not just plain text;
  3. error_prepend_string = "<pre>" (really important in some cases);
  4. error_append_string = "</pre>" (really important in some cases).

3 and 4 are needed for when PHP inserts the error in a HTML page with just new line characters and no <br> tags. Those settings will encapsulate the error inside a <pre> tag, so new line characters will be preserved.

Of course, you can add styles inside the <pre> tag. For example, I use

"<pre style='white-space: pre-line'>"

to allow line breaks on really long lines.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.