The set_exception_handler() is an inbuilt function of PHP and is used to generates a user-level error/warning/notice message. It will returns FALSE
if wrong error_type
is specified, TRUE
otherwise.
Example #1 trigger_error() function example
1 2 3 4 5 | <?php if ($usernum>10) { trigger_error("Number cannot be larger than 10"); } ?> |
Example #2 trigger_error() function example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?php include('functions.php'); $x = 'test'; doFunction($x); ?> functions.php: <?php function doFunction($var) { if(is_numeric($var)) { /* do some stuff*/ } else { trigger_error('var must be numeric'); } } ?> |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.