Forum Moderators: coopster

Message Too Old, No Replies

php 4 vs php 5

the difference

         

smallcompany

2:34 am on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This may sound as a stereotype but it’s a real life question for me.

I have a hosting plan where I control what to have installed. Among all, there are PHP 4.4.8 and PHP 5.2.6.

I personally don’t know anything about the difference between the two, but I do use PHP for some basic stuff (other people make it for me).
All what I have works fine under both 4 or 5, so far.

As a someone who knows PHP very well, how would you explain the difference (in short), and why would you use one over another?

If you really don’t care, please reply as that is also an answer.

Thanks

MattAU

4:20 am on Aug 29, 2008 (gmt 0)

10+ Year Member



Functionally, they're pretty similar. There are a few new features in 5 that IMHO make it better. Once you've used them (as a developer) for a while going back to 4 would be less than ideal.

The big thing is that support for PHP4 has ended completely. No more updates, no more security fixes, nothing. It's dead and buried. If there's problems with the last release (4.4.9) those problems are staying for good.

Given this, PHP5 is the only good option for any development and deployment at this stage. Until they release PHP6 :)

PHP_Chimp

8:30 am on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The oop part of php 5 is better than 4.

The largest reason for upgrading is the one that has already been made. PHP4 is no longer supported. So if you can choose then get everything upgraded. PHP4 code should work on php5, so the transition should be easy...having said that check it all first, just in case ;)

NameNick

10:06 pm on Aug 29, 2008 (gmt 0)

10+ Year Member



The performance of PHP 5 is better than PHP 4.

NN

coopster

3:19 pm on Aug 30, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Besides the others mentioned so far I would also add ...

New functions that make programming easier
XML support is better
DOM support is better
Date/time handling is better

I've also found bugs in some areas where the 4.x version was not addressed but PHP5 handles itself as I expect. I do development on a PHP5 platform and sometimes have to port the code to a PHP4 installation and I've run into issues. I'm trying to recall some of those areas and I believe FTP was one. However, I'm certain there were others, just cannot recall right now. I can go through comments in all the code I have and find my PHP4 workarounds but that would take me awhile.

Do yourself a favor, go with 5 :)

bysonary

6:00 pm on Aug 31, 2008 (gmt 0)

10+ Year Member



I have hit problems when developing in 5 and then using a production server running 4, some functions in 5 aren't available in 4, functions that for me make scripting in php mushc nicer, if someone else writes the scripts for you i would ask what platform their development machine is running and go for the same version, just to avoid any issues you may have in the future.

Thanks
Chris

MattAU

10:16 pm on Aug 31, 2008 (gmt 0)

10+ Year Member



if someone else writes the scripts for you i would ask what platform their development machine is running and go for the same version, just to avoid any issues you may have in the future.

I would do the exact opposite and tell the developer to make them work on my server - using PHP 5.

ghostdog

12:03 pm on Sep 2, 2008 (gmt 0)



as already stated, the OO (object oriented) part was like totally rewritten in php5. huge advance.

penders

3:57 pm on Sep 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I do development on a PHP5 platform and sometimes have to port the code to a PHP4 installation and I've run into issues. I'm trying to recall some of those areas and I believe FTP was one.

If you have PHP5 code that takes advantage of the new Object/class model then it could be very difficult to go back to PHP4. However, relatively easy to modify PHP4 code to work on a PHP5 platform (and most of the time you won't have to change a thing).

PHP5.0.0 to PHP5.3.0 offers zend.ze1_compatibility_mode to enable compatibility with PHP4 in some areas - if you should need it.

Also new for developers...
- Exception handling (Although not as useful as in other languages IMHO) [webmasterworld.com]

The OOP and XML handling is enough for me to not want to go back to PHP4. Only if you had a big app that you had to support and was stubborn enough to only work under PHP4 would you run PHP4, IMHO.

Migrating from PHP 4 to PHP 5.0.x [uk2.php.net]