I went to php.net's documentation, to learn about classes and such, only to find that there two different documentations of Classes and Objects each for PHP 5 and 4.
Now I don't know which one to read. I know I have php 4 on my server with a php 5 interpreter. I could activate my php 5 interpreter on my site, but I don't want to mess up any current php scripts.
So what I'd like to know is what are the major differences in the Objects and Classes in php 5 and 4? Is there really a big change?
PHP 5's OOP vs PHP 4's
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I would recommend trying PHP5 as there are usually few or no problems upgrading. PHP4 will no longer be supported.
I just upgraded a server that hosted many sites using PHP4. The process was pretty easy. In fact, PHP5 actually found a few bugs!. The main thing I found was that old SERVER vars had to be renamed. One of our members, Infolock, just wrote an article for php|architect about this I believe.
I just upgraded a server that hosted many sites using PHP4. The process was pretty easy. In fact, PHP5 actually found a few bugs!. The main thing I found was that old SERVER vars had to be renamed. One of our members, Infolock, just wrote an article for php|architect about this I believe.
(#10850)
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Okay. PHP 5 looks great. But what I'm concerned about is if I changed my php compiler over to php 5, what should I expect, error wise? What major differences are there between the two that might effect my current php scripts?superdezign wrote:PHP4 isn't exactly "real" OOP, as it is missing a lot and is generally considered hackish. PHP5 is much more pure.
I'm still really coming to grips with php5 oop, so I cant say I'm a really good judge of exactly what has changed.
I have however just switched a few classes made in php4 to a php5 environment, and had surprisingly few issues.
Actually, to be honest, I can only recall two problems (though each one numerous times).
Class variable definition changes from to
And creating instances by reference is depreciated. So should be in php5, however the behavior is the same.
There were some minor issues elsewhere, but nothing specifically OOP related. I'm certainly not saying that other issues might not be present, I'm just saying these were the only real issues in my conversions. But then, my php4 classes were pretty basic.
Hope this helps
I have however just switched a few classes made in php4 to a php5 environment, and had surprisingly few issues.
Actually, to be honest, I can only recall two problems (though each one numerous times).
Class variable definition changes from
Code: Select all
var $myClassVar;Code: Select all
public $myClassVar;Code: Select all
$instance = &new myClass();Code: Select all
$instance = new myClass();There were some minor issues elsewhere, but nothing specifically OOP related. I'm certainly not saying that other issues might not be present, I'm just saying these were the only real issues in my conversions. But then, my php4 classes were pretty basic.
Hope this helps