Is PHP Object-oriented? Is PHP Object-oriented? php php

Is PHP Object-oriented?


No, PHP is not fully object oriented language.

And neither is C++ or Java, because they all have primitive types (and PHP also has a huge collection of function like str_replace() and is_*(), which are clearly procedural in nature). Only pure object-oriented language, that i know of, are Ruby and Scala (and one could argue that latter is more aiming at functional programming paradigm).

PHP is, what one could call, "object-capable language".

As for the code written in PHP, you have to understand that just because you are using classes, it does not make it OOP. Especially if your code is mostly based on static class.

So, if you ask: "is CakePHP an OO framework?", then the answer is - NO. The most flattering description for it would be "class oriented programming". The code-base is filled with static methods and variables, where class acts more like a namespace. Basically CakePHP is a procedural code, wrapped in syntax, which on surface mimics object oriented code.


Yes, the latest versions of PHP are object oriented. That is, you can write classes yourself, use inheritance, and where appropriate, the built in functionality is built in objects too (like MySQL features).

There are still a lot of loose functions however, so there might be a disagreement about how object oriented PHP is. I think it is. And yes CakePHP is an object oriented framework.


PHP is not fully object oriented but it supports some feature like

1) class
2) object
3) Constructors and Destructors
4) Object Inheritance
5) Scope Resolution Operator (::)

and many more. If you want to learn object oriented php refer the below reference link

1) http://php.net/manual/en/language.oop5.php