ID:               22393
 Comment by:       michael dot mauch at gmx dot de
 Reported By:      tom dot polak at post dot cz
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Windows, but all
 PHP Version:      4.2.3
 New Comment:

Have a look at
<http://www.php.net/manual/en/function.set-error-handler.php>, then
use an error handler like in the example:

// error handler function
function myErrorHandler ($errno, $errstr, $errfile, $errline) {
  print("Error {$msg} in file {$errfile} on line {$errline}\n");
}

where you get $errfile and $errline without problems. For your extra
errors, you can use the trigger_error function.


Previous Comments:
------------------------------------------------------------------------

[2003-02-24 08:11:18] tom dot polak at post dot cz

Hello,
First, I have found similar request as #13944, 
but there is NO SOLUTION EXPLAINED, only closed.
If this request is solved, then my request is solved too, 
but how was #13944 solved?

I am trying to write error handler function as follows:

function ErrorHandler($msg,$file=__FILE__,$line=__LINE__){
  print("Error {$msg} in file {$file} on line {$line}\n");
}

which can be called from any php script when error occurs:

...
if($somethingwrong){
 ErrorHandler("something wrong");
}

I can to see the $file and $line pointing to the place, 
from which is ErrorHanlder function called.
But currently I see allwys the same file and line 
of the ErrorHandler function itself.

This request is based on big amount of php script files, 
where is not so simple to found, where the error condition 
occurs. Because the $msg itself is often not enough to 
explain the point in source code.

Secondary, I need to have own errorhandler, because 
using some features when the error appears in SQL command, 
there is more additional information displayed (not 
showed in example above, because is not relevant to this request). I am
logging errors by its type to several 
locations, conditionally email it to response admin
and other things.

Because of hunderts calls of ErrorHandler, using __FILE__
and __LINE__ is very time and place consuming.

With hope, that this description is understandable, 
even my poor english knowledge.

Best regards,
Tomas Polak
[EMAIL PROTECTED]

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22393&edit=1

Reply via email to