-1

This is a beginner's question -- surely already answered but I don't know how to find it:

When a coding/system error message pops up during processing of a PHP script or possibly JavaScript, its title is usually "The page at localhost [or other URL] says:". Its content usually includes a load of non-rendered HTML code (<b>, <br>, etc), a long reference to a PHP manual, an actual error message, and a reference to where the error occurred. Because the HTML is being ignored, the whole dialog is hard to read.

How can I get such windows to appear styled properly, as surely intended by the "folks at PHP or JavaScript", or at least appear in simple text with line breaks?

Please note: It is not an error message that I am intending to pop up in response to any user action; I don't know what is causing the message. Also, I'm not seeking advice on how to make user-friendly software or on how to do continuous development-and-delivery

Martin F
  • 590
  • 7
  • 28
  • Are you talking about a javascript alert? They can't be styled. They are built into the browser and exist at a layer a webpage can't access. You could use something like a jquery ui dialog to replace an alert. – Jonathan Kuhn Aug 21 '13 at 19:18
  • This is perhaps an AJAX library doing a request to a PHP script, the PHP script has error reporting enabled so that the AJAX library has problems parsing the response (e.g. invalid XML or JSON) and therefore gives an alert of the response. Or the HTTP response code is not 200 because of the error and the javascript then goes into the error handler for the AJAX request and that displays an alert. Maybe that? – hakre Aug 21 '13 at 19:24
  • @JonathanKuhn (and MarcB and joellustigman I suppose): No, it's not not _my_ message. Yes, _I'm_ the cause of the error. Yes, I should be a better person/programmer and not make errors to begin with. _Somebody_ wrote those error messages and presumably they wanted others to be able to read them. – Martin F Aug 21 '13 at 20:54
  • @hakre: Maybe so, but i think your answer below is correct, thanks. – Martin F Aug 21 '13 at 21:21
  • I have long-since successfully coded a prototype web-based GIS application, and no longer seek an answer. However, *someone* has decided to "teach me a lesson" in response to a question of mine on another site and down-voted this question. So i came back to make an improvement... – Martin F Mar 22 '15 at 04:07

2 Answers2

1

How can I get such windows to appear styled properly, as intended?

I don't know which window you are talking about, however from the rest of your description it sounds to me that you want to turn HTML error off so to get the plain text version of the error messages.

PHP has a setting for that Docs:

html_errors boolean

Turn off HTML tags in error messages. The new format for HTML errors produces clickable messages that direct the user to a page describing the error or function in causing the error. These references are affected by docref_root and docref_ext.

So all you need to do is to turn if off, either in your php.ini:

html_errors = 0

Or within your code:

<?php

ini_set('html_errors', 0);

You might also be interested in:

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
0

Never have your errors show up in a production website!!

If you're talking about dealing with errors while you're developing, then check out the Whoops library. It'll give you everything you want, plus much more.

Here's a quote from their homepage:

whoops is a nice little library that helps you develop and maintain your projects better, by helping you deal with errors and exceptions in a less painful way.

Check out their demo here. You can click on the left side to go through the stack. Really cool.

joellustigman
  • 326
  • 2
  • 10
  • Could you remove your bold-text/heading, please? While it is good general advice, i don't think it is relevant to the rest of your advice -- which is much appreciated. Thanks. – Martin F Aug 21 '13 at 22:15