Call getter to get value for property : Getter Setter : Class PHP Source Code


PHP Source Code » Class » Getter Setter »

 

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";
?>


           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Getter Setter