[thelist] how object oriented is php4

Jackson Yee jyee at vt.edu
Sun Mar 30 12:18:13 CST 2003


"Kelly Hallman" <khallman at wrack.org> wrote in message
news:Pine.LNX.4.44.0303292014320.3390-100000 at clove.wrack.org...
> 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..

No argument there.  PHP for small-medium sized websites is great in terms of
both time of development and features.  I'd still use JSP for larger
websites though: more time to develop, but much more capabilities such as
shared memory and server internal responses.

> 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.

That depends on the object you're copying.  If you're copying a huge object,
it can definitely impact performance.  The difference is that in the first
call, you're creating an object, then copying it.  In the second call,
you're creating a namespace reference to the original object, so there's no
copying involved.

(Says the guy who tries to squeeze every ounce of performance out of his
scripts)

> Consider the referencing/dereferencing nightmare in perl!

Let's not go there.  ;-)

> What do you mean by lacks easy reference notation?

Take a look at http://ny1.php.net/introtophp5.pdf for new referencing
features in PHP5.  Mainly, all objects will be references by default, and a
couple of other nice time/mind savers as well.

> Can you give an example of a destructor?

It's in the link above, but it basically saves you the task of explicitly
closing resource connections like fopen()/fclose() or opendir()/closedir().
It's one of the greatest advantages of C++/Java memory management versus C.

> 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.

I tried Python for a while, but the tabbing in procedures and blocks started
driving me crazy after a while.  I came from a C++/Java background though,
so that's why PHP's been both easy to pick up, and incredibly annoying for
me.

--
Regards,
Jackson Yee
jyee at vt.edu




More information about the thelist mailing list