[thelist] how object oriented is php4

Kelly Hallman khallman at wrack.org
Sun Mar 30 04:46:44 CST 2003


On Fri, 28 Mar 2003, Jackson Yee wrote:
> PHP5 will be much superior to PHP4 in terms of OOP functionality, but
> alas, it hasn't even reached alpha stage yet.  In the meantime,
> programmers like myself who are used to using C++ and Java will have to
> code around PHP4's lack of functionality.

PHP is a very endearing language I think.  It's quick to learn and has a
feature depth that seems to exceed nearly every other competing web
scripting language.  What is possible using procedural programming in PHP
makes it a very attractive choice already, and then you have the ability
to write fairly functional OOP code as well...even if you do have to
sometimes come up with workarounds to emulate missing OOP features..

It is not a true object-oriented language, but it is rare that a typical
PHP project (a web-based application) requires such OOP features in the
way they might be more critical when developing a voluminous non-web
application (such as coding a GUI) using OOP in another language.

My take: what's there is a good start.  PHP5, here we come!

> i.e. You must do
> $foo =& new bar();
> rather than
> $foo = new bar();
> in order to have the actual object instead of a copy of the object

This may seem illogical but I doubt it creates a big performance hit and
there is no functional difference between the two, since it's a new
instance either way.  Also, if there are no args, you can omit () w/ new.

I'd consider PHP an entry-level programming language, and having the
default assignment operator produce a copy instead of a reference seems
more convenient to the casual programmer who may not be aware of the
difference or when a reference is preferable and why.

Consider the referencing/dereferencing nightmare in perl!

> PHP4 has very limited support for OOP, especially the lack
> of destructors and easy reference notation.

What do you mean by lacks easy reference notation?
Can you give an example of a destructor?

> If you really want to play around with an object-orientated scripting
> language, try Ruby at http://www.rubycentral.com/book/

Thank you for this link!  I have been intrigued by Ruby but dismayed at 
the apparent lack of decent English documentation before I saw this.

I'll add that those interested in exploring OOP should check out Python,
which seems like Ruby's popular brother.  Again, purists may cite minor
Python OOP idiosyncrasies, but hey: when you find the perfect language,
let us all know...!  Python taught me more about programming techniques,
OOP, habits and discipline than any language I've come across to date.

In fact, it was the beauty of Python that piqued my interest in Ruby..
http://diveintopython.org/

-- 
Kelly Hallman
http://wrack.org/



More information about the thelist mailing list