Using Abstract Classes in PHP 5 : Abstract Class « Class « PHP






Using Abstract Classes in PHP 5

 
<?php
     abstract class Number {
          private $value;
          abstract public function value();
          public function reset() {
               $this->value = NULL;
          }
     }

     class Integer extends Number {
          private $value;
          public function value() {
               return (int)$this->value;
          }
     }

     $num = new Integer; /* Okay */
     $num2 = new Number; /* This will fail */
?>
  
  








Related examples in the same category

1.Define abstract class
2.abstract class demo
3.Using Abstract Classes and Methods
4.abstract keyword is used to say that a method or class cannot be created in your program as it stands