[KLUG Programming] Subtley *NASTY* PHP4/5 Difference

Adam Tauno Williams awilliam at whitemice.org
Fri Apr 8 08:06:17 EDT 2005


> > a switch that disposes of objects based upon their type (pretty
> > common I suppose)
> I thought being able to avoid exactly that was the major selling
> point of object-oriented code.  Why can't each class know how to
> dispose of its own objects?

In this case, due to deficiencies in the design of the language.  

In this application I need to take a collection of data and objects of
arbitrary complexity and serialize it into an RPC call to be transmitted
to the server.  PHP is great for designing web application, but for
something like this it becomes a bit tortured.  First there is the
distinction between data (types) and objects, for instance "string"
cannot be subclassed.  In C# I'd declare an interface to provide the
serialization and deserialization methods and extend all the required
data types to implement my interface;  but PHP has discreet data types
(int, string, etc...) that are not objects - so "real" object oriented
programming isn't possible.  The only possibility would be to create int
and string classes and reimpilement [ shoe horn ] all the int and string
related functions into them as members, which would (a) be allot of work
and (b) probably very slow.

Perhaps PHP5 offers some kind of solution, but for know a mix of PHP4
and PHP5 is the world, and probably for a good time to come.

> > PHP4 lowercases all object/type names... while PHP5 seems to
> > retains all case on object/type names
> One more thing to throw on the pile :)

Yep.

> http://tnx.nl/php
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.kalamazoolinux.org/pipermail/programming/attachments/20050408/60c58c94/attachment.bin


More information about the Programming mailing list