+ 5

What is the main use of object oriented PHP

I need someone to explain or tell me how it is used in a real world situation

4th Nov 2018, 10:24 AM
Esiro Davies
Esiro Davies - avatar
4 Answers
+ 13
With OOP it is much more easier to scale your application. Adding new features, refactoring and a lot of stuff become easier. The easier the development, the happier the developer and his employer.
4th Nov 2018, 12:22 PM
Igor Makarsky
Igor Makarsky - avatar
+ 3
php serves as backend in web development.. you've probably opened thousands of websites,some/most of them are being served by php here..dig in https://www.sololearn.com/learn/PHP/1801/
4th Nov 2018, 11:35 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
The best about OOP is that you can decouple your code so that you can reuse every part as often as you want. An example: You write one class that handles database connections. Every time you want to fetch some data from the database you don‘t have to think again about how to call those mysql queries exactly. You just use your prewritten class. Or you write a validator for a form that passes the values that should be checked to a function validate() which returns just true or false. Or you write a class that contains some logic for your domain (calculate some price, or check some permission, or get the cheapest offer, or the shortest way home, or the pizza with the most stars, or whatever). You don‘t have to write stuff over and over again but instead you separate everything that repeats into separate classes and functions. Aaaand: small functions in not so big classes are sooo much easier to read and to debug!!! :-)
8th Nov 2018, 12:05 AM
KatharinaSt