Re: How to get error context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It Maq wrote:
Hi,

i need help because I'm unable to retrieve error's context. Below is the code that is working perfectly except the context that is not displayed:

<?php
    function error_handler($errno, $errstr, $filename, $lineno, $errcontext)
    {

try doing a print_r($errcontext) here and see what you get?

maybe the zero index does not exist.

$str = "";
        $str .= "<br><br>ERROR Number: ". $errno;
        $str .= "<br>ERROR MESSAGE: ". $errstr;
        $str.= "<br>File: ". $filename;
        $str.= "<br>Line number: ". $lineno;
        $str.= "<br>Context: ". $errcontext[0];
        echo $str;
    }

echo "<h1>Testing set_error_handler</h1>";


I have always used
error_reporting(E_ALL);
instead of this.
error_reporting(0); set_error_handler('error_handler'); ini_set('error_reporting', 0);

I have never seen the above line before. This and the error_reporting(0) would probably suppress all error messages generated by PHP. Double check these settings and make sure the you can still trigger an error with trigger_error() if you have error_reporting() turned off.


//trigger_error("The string for testing the error", E_USER_WARNING);
$ourFileName = "testFile.txt";
$fh = fopen($ourFileName, 'X');// or die("Can't open file");
fclose($fh);


?>




      ____________________________________________________________________________________
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux