Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4023838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:38:51+00:00 2026-05-20T10:38:51+00:00

Whenever PHP outputs an error message it disregards css and a beautifully designed page

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:38:52+00:00Added an answer on May 20, 2026 at 10:38 am

    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() and print() sends what you are echoing/printing straight out, unless it’s in an output_buffer block (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 print the page content out to the output buffer, but in this case you are using an echo, which sends the string data directly to the buffer AT THAT MOMENT.

    For instance:

    Your problem in a simple example

    <?php
    
    $mystr = "<html>";
    $mystr .= "<body><h1>Hello World</h1></body></html>";
    
    echo "<head></head>";
    
    echo $mystr;
    
    ?>
    

    Which would give me on output to the browser:

    <head></head><html><body><h1>Hello World</h1></body></html>
    

    I am storing the string data, but echoing the HEAD block before I echo the other html data.

    What I need to do instead:

    <?php
    
    $mystr = "<html>";
    $mystr .= "<head></head>";
    $mystr .= "<body><h1>Hello World</h1></body></html>";
    
    echo $mystr;
    
    ?>
    

    Which would give me on output to the browser:

    <html><head></head><body><h1>Hello World</h1></body></html>
    

    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, and set_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.

    error_reporting(0);
    
    set_error_handler('phpLogError');
    
    function phpLogError() {
        $error = error_get_last();
    
        if ($error['type'] == 1) {
            //do your stuff    
        } 
    }
    
    function phpGetLoggedErrors() {
        // return your prettified html errors
    }
    

    Or, in other words…

    php_error_handle.php

    <?php
    
    $GLOBAL['_logged_php_errors'] = array();
    
    error_reporting(0);
    
    set_error_handler('phpLogError');
    
    function phpLogError() {
        global $_logged_php_errors;
    
        $error = error_get_last();
    
        if ($error['type'] == 1) {
            $_logged_php_errors[] = "<span>$error</span>";
        } 
    }
    
    function phpGetLoggedErrors() {
        global $_logged_php_errors;
    
        return "<ol><li>".implode('</li><li>',$_logged_php_errors)."</li></ol>";
    }
    
    ?>
    

    other.php

    <?php
    
    require_once 'php_error_handle.php';
    
    // other stuff, pages included/required, etc...
    

    Just make sure this require_once happens at the first line of code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem implementing custom 404 error pages on my Windows/IIS/PHP webhost. Whenever
Whenever I indent HTML in PHP mode, emacs (22.1.1, basic install on Redaht Linux
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
Whenever I run any jython program in Eclipse, I got the following error in
Whenever I design a database, I always wonder if there is a best way
Whenever I try to add a new project to my SourceSafe repository it creates
Whenever I type a (, [, or {, Notepad++ completes it with the corresponding
Whenever I'm at a break point in a certain C#.NET application in Visual Studio
Whenever I restore a backup of my database in SQL Server I am presented
Whenever I use the signal/slot editor dialog box, I have to choose from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.