PHP VERSION: 7.0.24

throwable_interface_example.php

<?php
// throwable interface demo

function do_something($obj) {
    
$obj->nope();
}

try {
    
do_something(null); // in PHP 5.x: oops!
} catch (\Error $e) {
    echo 
"Error: {$e->getMessage()}\n";
}
    

Output


Error: Call to a member function nope() on null
SOURCE CODE