custom error script taking too long.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nate  Baxley

    custom error script taking too long.

    OK, I'm taking my first stab at a custom error handler. Here's what
    I've got but it takes a very long time to return. If I remove the die
    command it reutrns much faster, but then I get several error messages
    when I only want one. Any ideas?

    Nate Baxley

    function ErrorHandler($c ode, $msg, $file, $line) {
    ?><h1>Somethin g wrong has happened</h1>
    <?
    echo('<strong>E rror: <em>' . $msg . '</emon line <em>' . $line .
    '</em></strong>');
    $bt=debug_backt race();
    echo('<table cellpadding="2" cellspacing="1" border="1"><cap tion
    style="text-align:left; font-weight:bold; color:red;">Bac ktrack
    Report</caption><tr><th >Line</th><th>File</th></tr>');
    for ( $i=0; $i<count($bt); $i++) {
    echo('<tr><td>' . $bt[$i]['line'] . '</td><td>' . $bt[$i]['file'].
    '</td></tr>');
    }
    echo('</table>');
    die();
    }

  • IchBin

    #2
    Re: custom error script taking too long.

    Nate Baxley wrote:
    OK, I'm taking my first stab at a custom error handler. Here's what
    I've got but it takes a very long time to return. If I remove the die
    command it reutrns much faster, but then I get several error messages
    when I only want one. Any ideas?
    >
    Nate Baxley
    >
    function ErrorHandler($c ode, $msg, $file, $line) {
    ?><h1>Somethin g wrong has happened</h1>
    <?
    echo('<strong>E rror: <em>' . $msg . '</emon line <em>' . $line .
    '</em></strong>');
    $bt=debug_backt race();
    echo('<table cellpadding="2" cellspacing="1" border="1"><cap tion
    style="text-align:left; font-weight:bold; color:red;">Bac ktrack
    Report</caption><tr><th >Line</th><th>File</th></tr>');
    for ( $i=0; $i<count($bt); $i++) {
    echo('<tr><td>' . $bt[$i]['line'] . '</td><td>' . $bt[$i]['file'].
    '</td></tr>');
    }
    echo('</table>');
    die();
    }
    >
    Sorry, I am new to PHP but would it not be better to create an
    ErrorHandler Class object instead of a single function? I am sure you
    can find some samples from with some of the PEAR packages to use as an
    example to build yours.

    --
    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)

    Comment

    Working...