Whenever PHP outputs an error message it disregards css and a beautifully designed page by outputting the message at the top of the page removing anything that stands in its way.
for example
some code} else {
echo "error, please do something!";
How do I get it to (or ask it nicely) to output the text inside a div that already exists inside my css so that it will obey the formatting and alignment rules that comes with that div.
EDIT
Actually, I just realized the “error” you’re talking about involves an echo/print out. Here’s the problem.
You’re
printing (echoing) the string error DIRECTLY TO the output buffer (which sends the HTML to the browser when you’re finished running all your code).echo()andprint()sends what you are echoing/printing straight out, unless it’s in anoutput_bufferblock (I won’t confuse you with details on that).So, you’re managing your regular html/text output in such a way as to NOT
printthe page content out to the output buffer, but in this case you are using anecho, which sends the string data directly to the buffer AT THAT MOMENT.For instance:
Your problem in a simple example
Which would give me on output to the browser:
I am storing the string data, but
echoing the HEAD block before Iechothe other html data.What I need to do instead:
Which would give me on output to the browser:
I am storing the string output (your error, in this case) until I need to output it later. This is what you need to know, and accomplish in your code.
I would investigate
error_reporting(0)/display_errors,error_get_last, andset_error_handler.http://www.php.net/manual/en/function.error-reporting.php
http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
http://php.net/manual/en/function.error-get-last.php
http://www.php.net/manual/en/function.set-error-handler.php
So that you could stop sending all errors immediately to the output buffer (which is why it’s at the top of the page), and then capture, store and present your errors.
Or, in other words…
php_error_handle.php
other.php
Just make sure this require_once happens at the first line of code.