PHP Function to return the most recent error.
I want a function that I can use to return the most recent error and error no. for an error function that I am putting together.
I have seen a lot of functions like mysql_error() and hw_error(), but I want one that would be general... Is there one standard, or will I have to make my own? ::Edit:: I am using PHP vers 4.3.6, but would be willing to hop over to ver 5 |
|
It is still kind of a problem... I don't think I explained well enough.
I need a function that I can call anywhere I want to, to return me the last error that happened in the script. The set_error_handler function won't do that job. I can have the script automatically do certain things on error with that, but I want the errors to be more in my own control. Most notices I would want the user to never see and the script to keep running, but every now and then there is one I feel the user should be aware of. I want to be able to use this function as I see fit... Such as. Code:
if($result = @mysql_query($query)){ Code:
$errorno = error_no_function_I_need(); |
Now that I think of it, a function that would grab the current line and file-name/path would be pretty sweet too.
|
You may look at http://fr2.php.net/manual/en/function.error-log.php and once your error log you have an error history which you can play with it.
And for : "a function that would grab the current line and file-name/path", there is an example at the URL I wrote above |
__LINE__ Is a pseudo constant that contains the corrent line number.
__FILE__ Is a pseudo constant that contains the current filename. if you go into the php.ini file and change track_errors from Off to On: $php_errormsg contains the message from the last error that occured. |
All times are GMT -5. The time now is 01:55 AM. |