From: Sebastian Bergmann Date: Mon, 14 Jan 2002 12:14:18 +0000 (+0000) Subject: Update Exceptions example. X-Git-Tag: PRE_ISSET_PATCH~195 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e1957044d7d9e1b58b0bd862fa625a36cb400f7;p=php Update Exceptions example. --- diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 49e5e239de..f17f4e3003 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -321,30 +321,31 @@ Changes in the Zend Engine 2.0 error = $_error; + function __construct($exception) { + $this->exception = $exception; } - function getException() { - return $this->error; + function Display() { + print "MyException: $this->exception\n"; } } - function ThrowException() { - throw new MyException("'This is an exception!'"); + class MyExceptionFoo extends MyException { + function __construct($exception) { + $this->exception = $exception; + } + + function Display() { + print "MyException: $this->exception\n"; + } } try { - } catch ($exception) { - print "There was an exception: " . $exception->getException(); - print "\n"; + throw new MyExceptionFoo("Hello"); } - try { - ThrowException(); - } catch ($exception) { - print "There was an exception: " . $exception->getException(); - print "\n"; + catch (MyException $exception) { + $exception->Display(); } ?>