From b18c565926514ec82f6bc98cbc43d1193181ef9f Mon Sep 17 00:00:00 2001 From: David Mytton Date: Mon, 4 Apr 2005 18:00:21 +0000 Subject: [PATCH] Added example git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@183591 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../functions/restore-error-handler.xml | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/reference/errorfunc/functions/restore-error-handler.xml b/reference/errorfunc/functions/restore-error-handler.xml index 1be16b63c4..dfe9787199 100644 --- a/reference/errorfunc/functions/restore-error-handler.xml +++ b/reference/errorfunc/functions/restore-error-handler.xml @@ -1,5 +1,5 @@ - + @@ -26,6 +26,68 @@ restore_exception_handler, trigger_error. + + The example below shows the handling of internal exceptions by + triggering errors and handling them with a user defined function. It then + restores the original PHP error handling: + + + Error handling with <function>set_error_handler</function>, + <function>trigger_error</function> and + <function>restore_error_handler</function> + + +My FATAL [$errno] $errstr
\n"; + echo " Fatal error in line $errline of file $errfile"; + echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")
\n"; + echo "Aborting...
\n"; + exit(1); + break; + case ERROR: + echo "My ERROR [$errno] $errstr
\n"; + break; + case WARNING: + echo "My WARNING [$errno] $errstr
\n"; + break; + default: + echo "My unkown error type: [$errno] $errstr
\n"; + break; + } +} + +set_error_handler("myErrorHandler"); +trigger_error('Test error', ERROR); + +restore_error_handler(); // Will restore standard PHP handler +trigger_error('Test error', ERROR); +?> +]]> +
+ &example.outputs.similar; + + + +
+