Hi, A while ago I proposed a patch that improved html_errors, but i got no response from that, so i repost an improved version...
The patch changes they way errors are displayed: 1) They are readable. The current version prints in black with no background at all, sometimes leading to black error messages on dark backgrounds - not very readable. Additionally, they have a fixed font size so they don't appear in a 4px font somewhere. 2) They are colorized. Notices, warnings, fatal errors and other errors get distinct colors for a better quick overview. 3) They look better ;) It uses CSS to format the error message nicely. The colors used are changeable by php.ini directives. Since many people just debug in their browser without using own error_handlers or append/prepend_strings, i think this is a nice addition that makes php more user-friendly. An example of how this looks can be found at: http://prp0.prp.physik.tu-darmstadt.de/~swalk/errors.htm Regards Stefan
Index: main/main.c =================================================================== RCS file: /repository/php-src/main/main.c,v retrieving revision 1.562 diff -u -r1.562 main.c --- main/main.c 30 Jul 2003 16:15:03 -0000 1.562 +++ main/main.c 5 Aug 2003 06:02:39 -0000 @@ -340,6 +340,11 @@ STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_ALL, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("always_populate_raw_post_data", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, always_populate_raw_post_data, php_core_globals, core_globals) + PHP_INI_ENTRY("html_errors.notice_color", "#bfb", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.warning_color", "#fea", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.fatal_color", "#fbb", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.other_color", "#fff", PHP_INI_ALL, NULL) + PHP_INI_END() /* }}} */ @@ -659,6 +664,7 @@ if (display && (EG(error_reporting) & type || (type & E_CORE)) && (PG(log_errors) || PG(display_errors) || (!module_initialized))) { char *error_type_str; + char *error_color_str; switch (type) { case E_ERROR: @@ -666,22 +672,27 @@ case E_COMPILE_ERROR: case E_USER_ERROR: error_type_str = "Fatal error"; + error_color_str = INI_STR("html_errors.fatal_color"); break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: error_type_str = "Warning"; + error_color_str = INI_STR("html_errors.warning_color"); break; case E_PARSE: error_type_str = "Parse error"; + error_color_str = INI_STR("html_errors.other_color"); break; case E_NOTICE: case E_USER_NOTICE: error_type_str = "Notice"; + error_color_str = INI_STR("html_errors.notice_color"); break; default: error_type_str = "Unknown error"; + error_color_str = INI_STR("html_errors.other_color"); break; } @@ -705,10 +716,13 @@ } else { char *prepend_string = INI_STR("error_prepend_string"); char *append_string = INI_STR("error_append_string"); - char *error_format = PG(html_errors) ? - "%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s" - : "%s\n%s: %s in %s on line %d\n%s"; - php_printf(error_format, STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + if (PG(html_errors)) { + char *error_format = "%s\n<div style='border:1px solid black;background-color:%s;color:#000;margin:2px;padding:2px;font-family:verdana,arial,helvetica,sans-serif;font-size:12px;'><b>%s</b>: %s in <b>%s</b> on line <b>%d</b></div>\n%s"; + php_printf(error_format, STR_PRINT(prepend_string), error_color_str, error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + } else { + char *error_format = "%s\n%s: %s in %s on line %d\n%s"; + php_printf(error_format, STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + } } } #if ZEND_DEBUG
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php