Avatar ·

What is the difference between public, private and protected in PHP?

Hello everyone! I just started learning OOP in PHP and can't understand the difference between access modifiers public, private and protected. I read the documentation but still get confused. Here's an example code I wrote: ```php engineNumber; } } $myCar = new Car(); echo $myCar->color; // Works echo $myCar->engineNumber; // Error! echo $myCar->vinCode; // Also error! ?> ``` Why can I access the $color property directly, but not $engineNumber and $vinCode? What is the fundamental difference between private and protected? When should I use which modifier? And how to properly organize ac