Why do we need classes in PHP? Why it is impossible to write everything in a procedural style, because it’s simpler and less code.
2 answers
OOP is needed so that you do not write the opposite code when the project is large. And this paradigm is simpler in terms of reading the code, in contrast to the procedural approach.
Here is a good article that will help understand object-oriented programming, there are just examples in PHP:
http://www.wh-db.com/article/chto-takoe-objecno-orientirovannoe-programmirovanie/
For small, amateur projects, the benefits of an object-oriented approach are small. But the more your project, the more rules, dependencies and special cases you need to keep in mind, the more participants you have in your project and thus the greater the need to reduce dependencies between parts of the code, the greater your gain from object-oriented design.
Note that OOP is not a keyword class, it is the design of the entire program, built in such a way that the internal affairs of each entity remain inside this entity and have no effect on other entities.
And the least of all the code will be if you refuse the procedures and use goto . Just what is your goal: less code or less development time?