OOP consists of programming languages that manipulate Objects. They tend to use data more than logic.

What are some advantages of OOP?

  • Code is really easy to reuse. We use lots of Classes, Objects and Methods/Functions that can be called throughout your program.
  • Encapsulation, which stops commands leaking outside of functions. Keeps everything in scope. You can keep all your data, functions .etc inside of a single object.
  • It’s often easier to design.
  • Easier to maintain, scale and debug!

What sucks about OOP?

  • A little complicated to learn if you’ve never done it before, or you’re from a procedural/linear programming background..
  • Requires a little extra thinking and sometimes planning
  • You need to write more code usually. However, when scaled, you’ll because to call methods that you’ve already written!

How do you change visibility in OOP?

You can usually change the visibility of your variables and methods by prefixing them with either:

  • Public; everyone can use
  • Private; only things in the same class or object can use
  • Protected; only things in the same class and/or extended classes can use

How do you instantiate a Class in PHP OOP?

You create a new variable,  then you make it equal to a new Class. This is now an Object.