diff options
author | Sebastian Bergmann <sebastian@php.net> | 2001-12-29 08:17:57 +0000 |
---|---|---|
committer | Sebastian Bergmann <sebastian@php.net> | 2001-12-29 08:17:57 +0000 |
commit | 76cfd48f729d71d4eea2ca897ea19b3e97c015e4 (patch) | |
tree | 86de2c943465eedbb14aeb5efbdfffd5e165cfbe | |
parent | 9311e0511981c30d41392ad036a6d76f037b47dc (diff) | |
download | php-git-76cfd48f729d71d4eea2ca897ea19b3e97c015e4.tar.gz |
Update Exceptions example.
-rw-r--r-- | Zend/ZEND_CHANGES | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 57b02ea677..5f399ba4ec 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -47,22 +47,37 @@ Changes in the Zend Engine 2.0 Example - try { - code + <?php + class MyException { + function MyException($_error) { + $this->error = $_error; + } + + function getException() { + return $this->error; + } + } - if (failure) { - throw new MyException(Failure); + function ThrowException() { + throw new MyException("'This is an exception!'"); } - code - } catch ($exception) { - handle exception + try { + } catch ($exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } - throw $exception; // Re-throw exception. - } + try { + ThrowException(); + } catch ($exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } + ?> - Old code that does not use exceptions will run without - modifications. + Old code that does not define user-space functions 'catch', + 'throw' and 'try' will run without modifications. * Namespaces. |