]> granicus.if.org Git - php/commitdiff
Update Exceptions example.
authorSebastian Bergmann <sebastian@php.net>
Mon, 14 Jan 2002 12:14:18 +0000 (12:14 +0000)
committerSebastian Bergmann <sebastian@php.net>
Mon, 14 Jan 2002 12:14:18 +0000 (12:14 +0000)
Zend/ZEND_CHANGES

index 49e5e239deb02a3ccd2671f0496fdd102298dce7..f17f4e30032066739e7013b1cd44554c4837a81d 100644 (file)
@@ -321,30 +321,31 @@ Changes in the Zend Engine 2.0
 
         <?php
         class MyException {
-          function MyException($_error) {
-            $this->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();
         }
         ?>