Hàm restore_exception_handler () khôi phục trình xử lý ngoại lệ trước đó. Nó được sử dụng sau khi thay đổi hàm xử lý ngoại lệ bằng set_exception_handler (), để hoàn nguyên về trình xử lý ngoại lệ trước đó (có thể là hàm tích hợp sẵn hoặc do người dùng xác định).
Cú pháp
restore_exception_handler()
Tham số
- NA
Quay lại
Hàm restore_exception_handler () luôn trả về TRUE.
Ví dụ
Sau đây là một ví dụ -
<?php function customException1($exception) { echo "[" . __FUNCTION__ . "]" . $exception->getMessage(); } function customException2($exception) { echo "[" . __FUNCTION__ . "]" . $exception->getMessage(); } function customException3($exception) { echo "[" . __FUNCTION__ . "]" . $exception->getMessage(); } set_exception_handler("customException1"); set_exception_handler("customException2"); set_exception_handler("customException3"); restore_exception_handler(); // throwing exception throw new Exception("Triggers the first exception handler!"); ?>
Đầu ra
Sau đây là kết quả -
[customException1] Triggers the first exception handler!