note 92438 added to errorfunc.configuration
| From: | hutchike at gmail dot com | Date: | Fri, 24 Jul 2009 06:42:27 +0000 |
| Subject: | note 92438 added to errorfunc.configuration | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158675@lists.php.net to get a copy of this message | ||
If you want to avoid a fatal error when an undefined method call fails, you can add a simple
Exception thrower like this:
<?php
class MyClass
{
// ...lots of your regular code, then:
public function __call($name, $args)
{
throw new Exception('Undefined method ' . $name . '() called');
}
}
?>
This means your top-level code can simple run inside a
<?php try { call_a_method(); } catch (Exception $e) { handle_exception($e); } ?>
block, and catch the errors that were fatal before.
----
Server IP: 148.206.80.9
Probable Submitter: 189.130.167.64
----
Manual Page -- http://www.php.net/manual/en/errorfunc.configuration.php
Edit -- https://master.php.net/note/edit/92438
Del: integrated -- https://master.php.net/note/delete/92438/integrated
Del: useless -- https://master.php.net/note/delete/92438/useless
Del: bad code -- https://master.php.net/note/delete/92438/bad+code
Del: spam -- https://master.php.net/note/delete/92438/spam
Del: non-english -- https://master.php.net/note/delete/92438/non-english
Del: in docs -- https://master.php.net/note/delete/92438/in+docs
Del: other reasons-- https://master.php.net/note/delete/92438
Reject -- https://master.php.net/note/reject/92438
Search -- https://master.php.net/manage/user-notes.php