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 */
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.