public
- visible from anywhere
private
- visible only for the owner class
protected
- visible only for the owner and it's child classes
class User {
public $username;
public $friends = ['Tom','David'];
function __construct($name) {
$this->username = $name;
print $this->username . "'s object is created'\n";
}
private function მარტივიჯამი($num1,$num2) {
return $num1 + $num2;
}
}
class Admin extends User{
function sumNumbers($num1,$num2) {
return $this->მარტივიჯამი($num1,$num2);
}
}
$admin1 = new Admin('Tom');
echo $admin1->sumNumbers(4,5);