Abstract Classes

PHP 5 introduces abstract classes and methods. An abstract method only declares the method's signature and does not provide an implementation. A class that contains abstract methods needs to be declared abstract.

<?php
abstract class ab {
    abstract public function test();
}

/* the implementing class must implement all methods
 * specified in the abstract class */
class imp_ab extends ab {
    public function test() { 
        echo "implemented class was called";
    }
}

$a = new imp_ab();
$a->test();
?>

 


Loading ...

Related Results :

  1. Abstract Classes
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author