function call_method($obj) {
$obj->method();
}
call_method(null);
Fatal error: Uncaught Error: Call to a member function method() on null in file:2
Stack trace:
#0 file(4): call_method(NULL)
#1 {main}
thrown in file on line 2
<?php
try {
call_method(null);
} catch (Error $e) {
echo "Caught Exception: {$e->getMessage()}\n";
}
Caught Exception: Call to a member function method() on null