Creating A Class That Inherits From Another

<?php
class Item {
  var $name;  function Item( $name="item", $code=0) {
    $this->name = $name;
    $this->code = $code;
  }  function getName() {
   return $this->name;
  }
 } class PriceItem extends Item { } $item = new PriceItem( "widget", 5442 );
 print $item->getName ();
 ?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.