Linked by Kroc Camen on Sat 20th Dec 2008 17:54 UTC
General Development IBM delves into what's new in PHP 5.3: Part-1 shows you the changes to the object-orientated capabilities, and Part-2 shows you the exciting new possibilities with real closures and lambda functions. ["Read more" for Kroc's personal commentary]
Thread beginning with comment 340911
To read all comments associated with this story, please click here.
PHP5 is object oriented
by g2devi on Sat 20th Dec 2008 23:24 UTC
g2devi
Member since:
2005-07-09

> PHP can claim to be "Object Orientated" until the cows come home,
> but the fact of the matter is PHP's native objects and commands
> are still painfully procedural

Sigh. I think you're confusing PHP4 with PHP5. PHP5 *is* objected oriented, just as C++ is.
PHP5's object model was based on Java's and contains more object reflection and method interception
features than either C++ or Java (though less than Python and Ruby). The fact that you can program
nonobjected oriented and nonprocedurally using functions that are common to C and Perl is a plus,
not a minus. It makes training and transitioning code away from these languages to PHP easier.

The key thing lacking in PHP5 is a good object oriented alternative to functionality that's currently
only available in functions. PEAR and the Zend Framework fill in the gaps substantially so that you can almost not have to call a single non-objected oriented function again. But neither
are "standard" in the sense that Python, Ruby, and Java have a standard library.

Reply Score: 2

RE: PHP5 is object oriented
by Kroc on Sat 20th Dec 2008 23:35 in reply to "PHP5 is object oriented"
Kroc Member since:
2005-11-10

I write exclusively v5 for PHP. A language cannot be properly object-orientated if the base objects are themselves not objects. String, Array &c. are not object-orientated and any commands involving them are entirely procedural. Using libraries to dance around this doesn't change what PHP inherently is—a procedural language with objects tacked on.

I do understand what you’re saying, but having coded a lot of VB6, Javascript and PHP I know the limitations of hybrid languages.

Reply Parent Score: 7

RE[2]: PHP5 is object oriented
by tyrione on Sat 20th Dec 2008 23:40 in reply to "RE: PHP5 is object oriented"
tyrione Member since:
2005-11-21

I write exclusively v5 for PHP. A language cannot be properly object-orientated if the base objects are themselves not objects. String, Array &c. are not object-orientated and any commands involving them are entirely procedural. Using libraries to dance around this doesn't change what PHP inherently is—a procedural language with objects tacked on.

I do understand what you’re saying, but having coded a lot of VB6, Javascript and PHP I know the limitations of hybrid languages.


Don't know why you're getting marked down, other than the fact those marking you down don't know a damn thing about OOA/OOD, let alone OO Programming.

Reply Parent Score: 1

Bill Shooter of Bul Member since:
2006-07-14

We can argue semantics until the cows come home, care to elaborate on the limitations of the hybrid languages?

For my $.02, I'd prefer if they went to a perl6 style type system where you can declare an int as an int, so you could have an array element take less than 50 bytes. Rather than have int be an object.

Reply Parent Score: 0

RE: PHP5 is object oriented
by Saem on Sun 21st Dec 2008 08:58 in reply to "PHP5 is object oriented"
Saem Member since:
2005-07-06

I've been coding in PHP v5 for sometime now. On a large scale application in fact. During this time, I've experimented extensively with the language: I've gotten various forms of multiple inheritance, before traits came out, meta-programming with annotations, and a ton of other crazy features hacked up. All of that involved heavy use of magic methods (__call, __get, __set), and the rest of PHP's object system.

Just to make it clear, those are crap. You can't use them to satisfy interfaces or abstract methods of any sort. You don't even have options around point of entry, it's always last! PHP in my experience, is a poor, thin veneer atop C. At the same time, I've pushed it pretty far and it's kept up, sort of.

And then there is type hint, which is balls, it's great to help IDEs provide code completion, but in such a loosely typed language you'd think you'd be able to create juggling semantics for user defined types, otherwise you lose a lot of the dynamic nature of the language as you're shoe-horning a crap "static" type system.

Reply Parent Score: 3