Mega Code Archive
Use this keyword to reference interal properties
title = $title;
$this->firstName = $firstName;
$this->lastName = $mainName;
$this->price = $price;
$this->numPages = $numPages;
$this->stayYear = $stayYear;
}
function getNumberOfPages() {
return $this->numPages;
}
function getStayLength() {
return $this->stayYear;
}
function getFullName() {
return "{$this->firstName}" . "{$this->lastName}";
}
}
$product1 = new Employee("A", "A1", "A2", 5.99, 300 );
$product2 = new Employee("B", "B1", "B2", 10.99, null, 60.33 );
print "author: ".$product1->getFullName()."\n";
print "number of pages: ".$product1->getNumberOfPages()."\n";
print "artist: ".$product2->getFullName()."\n";
print "play length: ".$product2->getStayLength()."\n";
?>