Properties (attributes):
name
,
gender
,
username
,
email
Methods (behavior):
addFriend
,
deleteFriend
,
postStatus
,
follow
,
unfollow
class User {
    public $username;
    public $friends;
    
    public function addFriend($friend_name) {
        $this->friends[] = $friend_name;
    }
    
    public function removeFriend($friend_name) {
        $this->friends = array_filter($this->friends, fn ($m) => $m != $friend_name);
    }
}

$user1 = new User();
$user1->username = 'Adam';

$user1->addFriend('Tom');
$user1->addFriend('David');
$user1->addFriend('George');

$user1->removeFriend('David');
print_r($user1->friends);
echo $user1->username;
by Valeri Tandilashvili
5 years ago
PHP
OOP
Object Oriented PHP Tutorial
2
Pro tip: use ```triple backticks around text``` to write in code fences