<?php
class Person {
public $name;
private $nationalCode;
private $age;
protected $income;
public function __construct($name,$age){
$this->name=$name;
$this->age=$age;
$this->setNationalCode(rand(100,999));
}
#Setter
public function setnationalCode($nationalCode){
$this->nationalCode = $nationalCode;
}
public function setAge($age){
$this->age=$age;
}
public function setIncome($income){
$this->income=$income;
}
#Getter
public function getnationalCode(){
return $this->nationalCode;
}
public function getAge(){
return $this->age;
}
public function getIncome(){
return $this->income;
}
}
$loghman = New Person("Loghman Avand",32);
echo $loghman->name . '<br>';
echo $loghman->getAge(). '<br>';
$loghman->setIncome(5000000);
echo $loghman->getIncome(). '<br>';
echo $loghman->getnationalCode(). PHP_EOL;