Login or Register Now   Email:  Password:   

Ever wondered what an abstract class is? Well this little example should help you get started. Also check out the OOP tutorial at http://www.phpro.org/articles/Object-Oriented-Programming-with-PHP.php


<?php

  
// make sure it is broken
  
error_reporting(E_ALL);

abstract class 
media {

private 
$copyrightInfo;

abstract function 
play();

function 
setCopyrightInfo($info) {
  
$this->copyrightInfo $info;
}

// end of abstract class media

class cd extends media{

function 
play() {
  echo 
"The CD has started playing!";
}

// end class cd

  
$cd = new cd();
  
$cd->setCopyrightInfo("Copyrighted by who else? Me!");
  
$cd->play();

?>