PHP VERSION: 7.0.24

throwable_interface_shows_finally_and_destroy.php

<?php
// throwable interface demo

class Test
{
    public function 
doSomething($obj) {
        
$obj->nope();
    }
    public function 
__destruct()
    {
        echo 
"Destroy called\n";
    }
}

try {
    
$a = new Test();
    
$a->doSomething(NULL);
} catch (\
Error $e) {
    echo 
"Error: {$e->getMessage()}\n";
} finally {
    echo 
"Finally is called\n";
}

    

Output


Error: Call to a member function nope() on null
Finally is called
SOURCE CODEDestroy called