4

I have been surprised to learning that a number of my hosted sites only support 5.1.6, when my dev box is running 5.3.x. This is a huge disappointment, because I've been working with namespaces (5.3+) and other features that seem to me to be excellent, if not strictly necessary.

Anyway, when writing code that is designed to be portable (eg: plugins for popular platforms like WordPress), what version of PHP should I be targeting, based on the minimum version that's supported on the majority of web hosts out there.

Does anyone know? How can one find out?

2
  • I think it's 5.2.something, unless 5.3 has recently been "approved". Most hosts that I've seen don't support 5.3 yet. I could be out of date though. Commented Jun 10, 2011 at 18:17
  • IMO, if it's a back-end application, you should write code for the oldest supported version, and that is 5.3. Back-end applications generally requires more processing power: dedicated servers. If you have a dedicated server, you can easily install 5.3 yourself. Commented Jun 10, 2011 at 18:59

3 Answers 3

8

Check http://w3techs.com/technologies/details/pl-php/all/all out.

It contains a lot of PHP stats. As of 12 Dec 2012,

  • Version 5 is used by 96.4% of all the websites which use PHP.
  • Version 5.3 is used by 42.3% of all the websites which use PHP version 5
  • Version 5.2 is used by 52.8% of all the websites which use PHP version 5
Sign up to request clarification or add additional context in comments.

1 Comment

This is a pretty awesome resource, and more than I had hoped for. Thank you.
1

My godaddy hosting account is on 5.2.17. If you want code to be portable then I would go with a general baseline of 5.0 features, which is pretty big feature set.

3 Comments

I've got to disagree with this advice. There are significant API spec changes in both 5.1 and 5.2. If you have 5.2, design for that. Also, PHP is fairly aggressive about support end-of-life, as they've already discontinued support for 5.2.
That is fair, I am not talking about using 5.1,5.2 implementations, just language constructs available to them.
Fair enough, I guess the ".0" threw me off.
1

Anyway, when writing code that is designed to be portable (eg: plugins for popular platforms like WordPress), what version of PHP should I be targeting, based on the minimum version that's supported on the majority of web hosts out there.

When you write for a specific platform, check the system requirements of that platform. For example, Wordpress 3.1 supports PHP 4.3 and MySQL MySQL 4.1.2. The next version 3.2 will increase this to PHP 5.2.4 and MySQL 5.0. So just check the according website of the project you would like to code for.

5 Comments

That's excellent advice for specific frameworks / platforms.
And as WP is very conservative and having a large install base, I would even say that PHP 5.2.4 is pretty safe to deal with.
I have a number of clients with hosting.com and they're still on 5.1.3. What a bummer.
Tell hosting.com that even Wordpress has now switched to PHP 5.2. Probably they will change their PHP version then.
Ha. They won't upgrade existing accounts on shared servers. You have to sign up with a new account to get 5.3...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.