using access modifiers.

Use access modifiers before variables and functions in a class.

access modifiers type

public, protected, private

public

It can also be accessed from outside the class. Outside the class is the part that says here if you look at the code below.

<?php
    class classname
    {
        $property;

        $property = value;
    }

    here
?>

protected

It cannot be used outside of a class, but within the class and inherited classes.
Inheritance is not explained now, but as I'll explain later, you can easily use your own. What this means.

<?php
    class classname
    {
    $property;

    $property = value;
    }

    Here, protected by the Declaration of the properties available can not.
?>

private

It cannot be used outside of a class, only in that class. That is, it cannot be used in inherited classes.
So let's set an access constraint on the code we used in the previous tutorial. If you don't use access constraints, you will get a syntax error.
Therefore, please use it.

<?php
    class Car
    {
        public $wheels;
        public $doors = 4;
        protected $color = 4;
        private $size;
        private $company;
    }
?>

Cars also have functions.
The biggest feature is the ability to run, the ability to stop, and the ability to rotate. To implement these features, we apply functions.
Functions are called methods in the class.
In other words, if someone says a function, it means a general function, and if someone says a method, you can think of it as a method defined in a class.
Next time, we'll learn about methods.