Click to See Complete Forum and Search --> : OO in PHP 5 vs PHP 4.x


paulsjv
07-22-2003, 04:43 PM
So this is what I heard and I want to make sure I heard this correctly because if I did this is not a good thing IMO.

With PHP 5 coming out with the total rework of OO and how it works.... is it true that any script that runs OO written in the PHP 4.x or 3.x environment won't work? In other words am I going to have to rewrite all my classes that I've already written?

Like I said this is what I heard and I just want to verify if this is true or not.

thanks!

Moonglobe
07-22-2003, 06:23 PM
php5 is completely backwar-comaptible with php<5 class as long as there aren't any functions/variables/classes named:

__constrct()
__destruct()
__call()
__get()
__sleep()
instanceof
exeption
etc for other keywords

so unless you've got one of those functions/methods/vars everything should work fine.

Weedpacket
07-22-2003, 06:23 PM
There are changes, yes. Most notably that objects default to being passed by reference rather than value (more in the Java style, iow). Details of how PHP5's OO implementation differ from that of PHP4 are described here (http://www.php.net/zend-engine-2.php).

It's a matter of experimentation and testing, but you might not have to make many changes at all.

Bunkermaster
07-23-2003, 10:46 AM
all the code i developped OOwise works on both PHP4.x and PHP5

A good example can be found in http://www.bunkermaster.com click UDPLive (and yes one day i'll finish this site)

Weedpacket
07-23-2003, 05:38 PM
And of course, if all else fails, you can install the beta somewhere and try it out; that's what I've just started doing (took a while I know - had to make room on my dev box).

codeDV
07-24-2003, 04:42 AM
I am glad they are improving the OOP in PHP, as it leaves a lot to be desired.

Moonglobe
07-24-2003, 04:47 AM
just out of curiosity, is/was Perl generally considered object-oriented? im just wondering because i've had almost no experience with the language and PHP was originally just a perl.....what would you call it? anyway just wondering.

moon