Constructor in OOP in PHP
There is a special method
that will be called
at the moment of creating a new object
of the class. This method is called
__construct. Let's
make it in our class:
php<?php
class User {
public function __construct() {
echo '+++';
}
}
?>
Let's now create an object of the class and make sure that the method is called:
php<?php
new User(); // will output '+++'
?>
Задание 1
Make a constructor
for the Employee class.