Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP vs OO PHP - Which one to use? [closed]

Tags:

oop

php

I'm developing a web system using regular PHP. This was my first experience with PHP so the code is not legible nor clean. It mixes some HTML code with PHP. I'd say I have already done half of the code.

What are the real advantages of the Object-oriented PHP? The website is about books and book authors, using MySQL and Apache. So it's not a very complicated website.

like image 289
rlc Avatar asked Jul 12 '10 22:07

rlc


People also ask

Is OOP PHP better than procedural?

Object-oriented programming has several advantages over procedural programming: OOP is faster and easier to execute. OOP provides a clear structure for the programs. OOP helps to keep the PHP code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug.

Why PHP is not fully OOP?

Multiple inheritance is still not there in PHP So it not fully Object Oriented. If the basic language semantics allow for both paradigms, then it's commonly classified as an hybrid language. @Shakti Singh. Multiple inheritance is not a basic concept of OO.

Is PHP functional or OOP?

PHP is an object-oriented programming language that supports several concepts. Here are some of the popular OOPS concepts in PHP with real-time Here are some of the popular OOPS concepts in PHP with real-time examples.

Is PHP OOP similar to Java?

Both PHP and Java are open-source which means both languages are available for public usage and can be modified and redistributed. Both are Object-Oriented Programming (OOP) languages.


1 Answers

The real advantage of object-orientation: your code is better organized, easier to maintain, more modular (and thus easier to reuse), and potentially less brittle (because of encapsulation of state and implementation, and hopefully better security). (The cynic in me also says that if you learn object-oriented PHP, you take the first important step to leaving the PHP ghetto. Heh. Worked for me!)

There's already a lot of questions from PHPers moving into OO on Stack Overflow:

  • PHP Object Oriented or Not?
  • Is my PHP code object oriented?
  • Learning PHP Class

Not to mention that there are zillions of PHP object-oriented tutorials out there. My take: basically, yes, if you are writing PHP, you should probably be writing object-oriented PHP for anything beyond the most trivial of applications. There are lots of Rails-like frameworks for PHP that will make your life easier, and may help you become a better programmer.

like image 177
Tom Morris Avatar answered Oct 26 '22 23:10

Tom Morris