tags:

views:

82

answers:

2

Why all PHP Functions for (Array , String , Database etc. handling) arent True OOP Methods. We can just call them like 'static' methods anywhere. PHP5 and PHP6 advertise themselves as True OOP Languages , but what about Encapsulation then ? I think In a proper World all Array methods should belong to Array Class and String Methods should belong to String Class and so on ... like in Java and Ruby and other OOP Languages.

I love and know by heart nearly 100-200 of these functions and they are just so powerful. But why advertise as OOP Language when PHP Creators didnt took even Basic 'Encapsulation' into Design while creating the Language ? Let it be 'Hybrid Language' or something else. Haskell and LISP are popular in their fields and are termed as 'Functional Languages'.

So , Why stick to OOP 'Term' ?

Just name it like this ,

"PHP is a Hybrid Programming Language designed for Server Side Scripting." :)

Cheers! Rohit Chauhan

+5  A: 

These methods were created before PHP supported classes.

They call themselves OOP to attract programmers.

Also, there is no rule that an OOP language cannot have static methods.

SLaks
More like: PHP attracts beginners to their beginners layout, after which the irony sets in where people stay beginners in that language and just move on to something else like Python or Ruby.PHP could improve, but it would take a major overhaul that will break older scripts.
JonnyLitt
+1  A: 

While PHP is object oriented, the functions that you're referring to are largely included for legacy compatibility. Most PHP4 code (and...eep...even some PHP3 code) can run on PHP5 with little to no change thanks to this.

On the other hand, you make the point that it isn't inherently object oriented in nature. While this is true, the remaining portion of the language is object oriented. Since the developer cannot create functions like this (I'm not going to argue over whether create_function truly creates "objects" or not), it is moot as to whether this changes the status as an OO language. Sure, these functions cannot be overridden without the use of PHP plugins, but functionally speaking, the language possesses all of the characteristics (from a developer's perspective) of a "true" OO language.

mattbasta
Hm, I didn't get that second part about `create_function`. Could you please clarify? Thanks.
nikic