How to use set exception handler in PHP

This article describe about set_exception_handler() Function in PHP.
  • 1810

set_exception_handler() Function

This function set the user defined function to the handle exception.

During runtime this function generate its own way to handle the exception.

Old exception handler return by this function. or Null or failure if no any previous exception handler is define.

Syntax

set_exception_handler( exception_function)

Example

<html>
<body>
<?php
function myException($exception)
{
echo "<b>Exception:</b> " , $exception->getMessage();
}
set_exception_handler('myException');
throw new Exception('Uncaught Exception occurred');
?>
</body>
</html>

Output

pic22.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.