如何让PHP / JavaScript错误弹出窗口正确显示样式?

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

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:

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.