PHP 8.3.4 Released!

restore_exception_handler

(PHP 5, PHP 7, PHP 8)

restore_exception_handlerBir önceki istisna eylemcisini devreye sokar

Açıklama

restore_exception_handler(): true

set_exception_handler() ile istisna eylemcisini değiştirdikten sonra önceki istisna eylemcisini (yerleşik veya kullanıcı tanımlı bir işlev) devreye sokmak için kullanılır.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

Daima true döndürür.

Örnekler

Örnek 1 - restore_exception_handler() örneği

<?php
function istisna_eylemci_1(Exception $e)
{
echo
'[' . __FUNCTION__ . '] ' . $e->getMessage();
}

function
istisna_eylemci_2(Exception $e)
{
echo
'[' . __FUNCTION__ . '] ' . $e->getMessage();
}

set_exception_handler('istisna_eylemci_1');
set_exception_handler('istisna_eylemci_2');

restore_exception_handler();

throw new
Exception('İlk istisna eylemcisi tetiklenir...');
?>

Yukarıdaki örneğin çıktısı:

[istisna_eylemci_1] İlk istisna eylemcisi tetiklenir...

Ayrıca Bakınız

add a note

User Contributed Notes 1 note

up
14
rl7 at shinyblue dot net
10 years ago
Note that this does not work within an exception handler.

e.g.

<?php

function handler1(Exception $e) {
echo
"handler1\n";
restore_exception_handler();
throw
$e;
}
function
handler2(Exception $e) {
echo
"handler2\n";
}

set_exception_handler( 'handler2' );
set_exception_handler( 'handler1' );

throw new
Exception( 'might expect to see handler1, handler2' );

/* Outputs:
handler1
PHP Fatal error: Uncaught exception 'Exception' with message 'might expect to see handler1, handler2' in /tmp/demo.php:15
Stack trace:
#0 {main}
thrown in /tmp/demo.php on line 15
*/

?>
To Top