Call Getter To Get Value For Property

 
    <?php
class Employee {
    public $title;
    public $lastName;
    public $firstName;
    public $price;
 
    function __construct( $title, $firstName, $mainName, $price ) {
        $this->title     = $title;
        $this->firstName = $firstName;
        $this->lastName  = $mainName;
        $this->price     = $price;
    }    function getFullName() {
        return "{$this->firstName}" . " {$this->lastName}";
    }
}$product1 = new Employee("B", "B1", "B2", 5.99 );
$product2 = new Employee("A", "A1", "A2", 10.99 );
print "author: ".$product1->getFullName()."\n";
print "artist: ".$product2->getFullName()."\n";
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.