Jump to content

Error Handlers


tmallen

Recommended Posts

How can I add a a row for every error? I know I did this before, but lost the code. The reason that this is necessary: I want errors to build into a table which is positioned absolutely (bottom: 1em; left: 1em). I can only have one copy of the table, otherwise errors overlap each other.

 

What I have now doesn't work, and I'm not entirely sure why (I know it's crappy code, but error handling is a black box indeed, plus this is for a prototype CSS framework, so I'm not being picky):

<?php
$errors = "<table class='phpError'>"
    . "<tr><th>Level</th><th>Error</th><th>File</th><th>Line</th></tr>";
$errorCount = 0;

function golondrinaErrors($number, $string, $file, $line) {
    global $errors;
    global $errorCount;
    $errorCount++;
    $errors .=  "<tr><td>" . $number . "</td>"
        . "<td>" . $string . "</td>"
        . "<td>" . $file . "</td>"
        . "<td>" . $line . "</td>"
        . "</tr>";
    return true;
}
if($errorCount > 0) {
    $errors .= "</table>";
    echo $errors;
}

set_error_handler('golondrinaErrors');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.