Properties Through Constructor Parameters in OOP in PHP

Variables passed through constructor parameters can be written to object properties:

php<?php
  class User {
    public $name;
    public $surn;
    
    public function __construct($name, $surn) {
      $this->name = $name;
      $this->surn = $surn;
    }
  }
?>

Thus, the passed values will become available in all methods of the class. As an example, let's use the passed values in some method:

php<?php
  class User {
    public $name;
    public $surn;
    
    public function __construct($name, $surn) {
      $this->name = $name;
      $this->surn = $surn;
    }
    
    public function show() {
      return $this->name . ' ' . $this->surn;
    }
  }
?>

Let's check how this works. Let's create a new object, passing the user's name and surname as parameters to it:

php<?php
  $user = new User('john', 'smit');
?>

Now let's call our method:

php<?php
  echo $user->show();
?>
Задание 1

Pass to the constructor of the class Employee the name and salary of the employee and write them to the corresponding properties.

Задание 2

Create a method that will display the employee's name.

Задание 3

Create a method that will display the employee's salary.

Задание 4

Create a method that will increase the employee's salary by 10%.