Calling an Overridden Method (PHP 5 Syntax)
<?php
class Item {
private $name;
function __construct( $name="item", $code=0 ) {
$this->name = $name;
$this->code = $code;
}
function getName() {
return $this->name;
}
}
class PriceItem extends Item {
function getName() {
return "(price) ".parent::getName ();
}
}
$item = new PriceItem ("widget", 5442);
print $item->getName();
?>
Related examples in the same category