__construct
gets called when a new object of the class gets createdclass User {
public $username;
public $friends = ['Tom','David'];
function __construct($name) {
$this->username = $name;
// print "In BaseClass constructor\n";
}
public function addFriend($friend_name) {
$this->friends[] = $friend_name;
}
}
$user1 = new User('George');
echo $user1->username;