Programming
Article

Which Version of PHP Do You Use?

By Craig Buckler

An interesting question was raised by dvduval in the SitePoint forums recently: Should we stop coding for PHP4?In a perfect world, the answer is an emphatic ‘yes’ and this was the response most people gave. Few will question that PHP5 offers a more robust object model, requires less code, is more secure and has better performance. It’s also installed by most web hosts, although many offer both PHP4 and PHP5. Finally, PHP4 development and support has ceased: you should certainly be using PHP5 if you’re starting application development today.Unfortunately, we don’t live in a perfect world. Many applications were written when PHP4 was the undisputed platform of choice and updating legacy code to PHP5 may be difficult or offer no business benefits. It’s also possible to create applications which work on either PHP4 or PHP5. WordPress is a good example and, although there are plans to switch to PHP5 only, the developers recognize it will affect thousands of installations and plugins. It’s not an update which can be done on a whim.We’d like to know which version of PHP your web application uses. While I’d expect many people to be working with PHP5, it’s useful to know whether anyone is still writing PHP4-only applications or creating cross-platform code. Please vote on the SitePoint poll and let us know how you came to your decision by leaving a comment below.

tip: Do you want to learn PHP?

If you’re new to PHP or need a refresher, why not sign up for SitePoint’s PHP Live with Kevin Yank? It’s a 3-week interactive course which will help you learn PHP from experts and your fellow students.

More:
PHP
  • http://logicearth.wordpress.com logic_earth

    I use and only ever use PHP 5.3 (or the current latest version) unless I get paid a buttload of extra money. I personally do not rely on cheap shared host accounts. Far too limiting and open for security problems. So not having control over the version of PHP is not an issue.

  • Jake Noble

    It has to PHP 5.3. Anything else is just a pain.

  • Marin Todorov

    If you call using php5 a perfect world you need a reality check … really. Introducing the GOTO operator? Oh, man …

  • http://www.cemerson.co.uk Stormrider

    You don’t HAVE to use it just because it was introduced…

    • http://brianswebdesign.com skunkbad

      Exactly what I was thinking.

  • DevonRW

    I work in PHP 5.2 at my workplace. I’m not sure if we’ll update to 5.3 or just wait for 6.0 to be released…whenever that is…

  • http://www.krues8dr.com krues8dr

    I’ve pretty much switched over to PHP5 completely, and find myself spoiled as a result. (Lambda functions for array_walk? yes please!) That being said, I can’t quite accept the ridiculous choice of namespace conventions and haven’t started using them yet as a result.

  • http://lukemorton.co.uk Luke Morton

    I generally use 5.2.13 on most personal projects and 5.1.something at work. However I have been reading into using namespacing in OOP and this certainly makes 5.3 appeal to me.

  • Shawn

    I only use PHP 5.3

    People need to stop using or wanting to use PHP 4 and upgrade. It’s outdated. If it means your site will break, you’d better get ready for upgrading your code too. Stop being lazy…

  • toastyghost

    “updating legacy code to PHP5 may be difficult or offer no business benefits”

    this. i’m trying to convince others where i work that the next major version of our data management tool needs to be php5-only, though.

  • Jory Geerts

    At work, we recently moved to PHP 5.3 (from 5.1, I beleave) for the development of anything new. But we do have some projects that still require some work every now and then, that are PHP 4. (And not even a “recent” PHP 4, but 4.0 or maybe 4.1) Nobody likes working on those projects, but if a customer who’s website was written in PHP 4 needs some work done, its really not worth it to port it to PHP 5. (Unless its a huge change that needs to be made, but then we might as well start from scratch.)

  • Ren

    5 is far superior to what has preceded it, 5.3 even more so, with closures, and even goto. Singling that out a as negative just shows how blinkered some can be.

    Next version 5.3.3, or 5.3.99 is looking tasty, fpm, some speedups, and memory savings with things like string interning.

  • mcksmith

    PHP 5 only for a number of years. Once we we switched to it at work, and my web host offered it, it wasn’t worth the effort to write backwards compatible code. I do switch between LAMP and WAMP at home, so I do write cross platform code.

  • RockBotom

    Started learning PHP using version 5.3. Haven’t had the pleasure of learning previous versions.

  • http://www.creativeclans.nl guido2004

    I use PHP 5.3. If your host doesn’t use the latest version, he’d better upgrade, or you could change hosting ;-)

    PHP5 has been released six years ago! Come on!

    • PHP?

      Switched to ColdFusion never looked back.

  • QuaffAPint

    I would love to, but when you sell scripts you want the largest market possible, and as long as my competition continues to offer PHP4 as an option, I got to stick with it as well.

    • http://rollerscapes.net s.stok

      PHP4 is no longer supported and maintained.
      Your taking an big risk using it, and by supporting it does encourage people to start using PHP5.

      I only support and use PHP5.3, god bless them namespaces.
      And Intl support!

  • SpacePhoenix

    With php4 having not been supported for well over a year, I can’t think of any valid reason why anyone has not at least started to migrate their sites/apps over to php5 as eventually all hosts will likely end their support for php4.

  • CdP

    Well, I see most people here speak about new projects only.
    Of course PHP 5 is better, but as far as I’m concerned, I have to work with an old application coded with PHP 4, tens of thousands of lines long, with many dependencies, and central to our society. Migrating it would be costful enough, and recoding is simply not an option.
    So, for new projects we use PHP 5, but we still need PHP 4…

  • momos

    5.3, the only way to go for now, namespaces are a necessity when your site consists of over 50 files, eagerly awaiting 6, unicode here we come…

    • Salathe

      … or maybe not. The old, major changes for unicode have been dropped.

      • momos

        seems like my info is a little old, why are we waiting so long for new version then?

  • Ryan

    My experience is that the change from 5.2 to 5.3 has been more of a pain than 4.x to 5.x

    On the server that we have and host websites for clients (and just hosting clients putting their own software on) we upgraded from 4 to 5 probably 4 years ago and it wasn’t that painful. however we tried the 5.2 to 5.3 upgrade and even with plenty of warning the amount of errors and issues were enough to roll the server back to 5.2.x

    I personally code for the latest release on all projects and use PHP’s early warning system to help make sure I’m not going to code any depreciated functions.

  • Alexxandar

    I use PHP 5.2, since more than 90% of sites I do are placed on shared hosting, 5.3 proved to bit too new. But everyone has 5.2 so it works great. PHP4 is a BIG no no, to much hassle for decreasing number of users.
    @QuaffAPint
    Rather than keep your competitions pace, encourage your clients to switch to PHP5 that way you will be ahead of them.
    Number of PHP4 users is only going to get smaller, and is it really that hard to find hosting with PHP5?

  • Beyta

    i started with PHP5…

    -beyta.net-

  • http://www.dahabtech.com firefoxegy

    i use PHP 5.3 and to be honest the new feature of Late static bindings made it easy to call the static inherited functions late http://www.php.net/lsb

  • spheroid

    For sites I develop custom, PHP5 using CakePHP 1.3.x. Unfortunately some sites I develop on use Pinnacle Cart which isn’t organized the most efficiently so that is why I prefer OOP with the MVC approach. Much faster development.

  • darksystem

    im using PHP 5 since the first stable release.

  • Anonymously

    I only use PHP 5.3

  • amdowney

    I had some old sites still running 4 and some running 5 with my old host. Since moving to my new host I have realised the importance to keep them all the same and that 4 poses security risks so 5 it is!

  • PHP Development Company

    PHP4 is still having very much popularity and Developers are quite comfortable with PHP4 i think. I am not saying PHP5 is not good as it is much advance but I still love PHP4

    • http://logicearth.wordpress.com logic_earth

      PHP4 and PHP5 are not that different couple of additions and changed default settings. Its not like PHP5 is a completely different language. What you are referring to is the workarounds/hacks to the problems of PHP4 as well as its deficiencies that developers are “comfortable” with.

      PHP5 fixes most of those problems. Saying you still love PHP4 is just odd and strange when you can do most of the stuff you did in PHP4 can be done in PHP5 just the same.

  • mario

    This reminds me a bit of the PHP3 goodbye. There is not much documentation how that fared back then. Sadly this article doesn’t contribte many interesting or concrete info points to the current PHP4 off transition either.

    • http://www.optimalworks.net/ Craig Buckler

      The transition from PHP3 to PHP4 took a while too … primarily because the register_globals default was changed from on to off for security reasons.

      However, there were far fewer PHP3 web sites and applications to update.

  • Rachel Andrew

    We made the decision a year ago to launch our mini CMS product Perch as a PHP5 app. As this is a self hosted product (people buy it and install it on their own server) and aimed at people who will be using shared hosting this was a bit of a risk.
    We have found however, that there have been very few problems. Either customers have just been able to ask their hosting company to upgrade them to PHP5 or the host runs both versions and with a switch in the .htaccess file they can use PHP5. It really hasn’t been an issue at all for us. We do support all versions of PHP5 and also PHP on Windows so have had to deal with all kinds of interesting issues with tiny differences between dot releases but the PHP4/PHP5 thing has been a non-issue generally.

  • http://www.aplossystems.co.uk AplosSystems

    I only use PHP 5.x (usually the latest stable version) since it is more secure, you can write less code and it has a better object model.

  • Skills2earn

    I use php 5.x because it is more secure and it has more functions.
    I also wrote some articles on php if soemone want to go through he can chk them on the link below:
    http://skills2earn.com

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in Front-end, once a week, for free.