The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I love using PHP 5 to do stuff, because it feels much more like writing in a real language than PHP 4 did. The expanded error message text when runtime errors occur is so much better than the stuff in PHP 4. I also like a handful of the new functions (file_get_contents() and file_put_contents() since i'm lazy as hell at times), as well as the expanded OOP implementation, despite the few steps taken away from the standards we see in C++ and Java (constructors not named for the class anymore...). Granted, I'm partial to much more powerful OO programming due to my background in C++ (i want function overloading , but we'd need types for it). I'm excited to hear of PHP 6, perhaps things will get even better.

I've developed a number of things using PHP 5-compliant code, however I haven't really taken full advantage of it except for in my latest endeavour, a crazy idea that I won't go into here...

More on topic, I blame hosts for the slow switch. Since the release of PHP 5.1, I judge it to be quite stable (i've been running since 5.0.3 i think, on windows with apache 2, all of which sounds like it should be crashing every 10 seconds) because I've had no issues whatsoever. Hosts should know how to administer their servers better than the average linux enthusiast, because they're getting money to do it. I set up php 5/apache 2/mysql 4 on linux for my school in an hour, and i don't consider myself to be much of a linux master.

For the most part, PHP 5 will run valid PHP 4 code (just some issues with MySQL if it isn't set up correctly), so I don't see how there is any problem with that sort of a transition--nothing needs to be recoded. I agree with everyone who said that the hosts should get off their butts and fix it--we're paying them to do it, they should serve us how we want to be served (within reason, and i don't see supporting php5 instead of 4 as too demanding).

I can't figure how you guys are so quick to burn the hosts at the stake. Hosts are running a business, and unless there is a pressing need for them to change what they are doing, well heaven forbid they should actually be meeting the needs of their business with PHP4! Damn them anyway! Come on, guys. Everybody loves a new little toy to play with, but let's get a grip and peek at the larger picture that is conveniently being ignored.

(And yes, I'm feeling annoyed and defensive. If you were a host, you would be too, after reading the "commentary" in this thread.)

There are two big reasons why we (my hosting company) are not using PHP5.

One, too many scripts are not PHP5 compliant. Last I looked, that problem rests right back squarely in the developers' laps. I don't write the scripts and it's not my job to patch them. I run servers. Now if I go and change my servers over to PHP5, the majority of my clients' scripts break dead, and I have hours and hours, days, weeks???? of support work to foot the bill on. Thanks but no thanks! When y'all can get the existing scripts out there actually running on PHP5, I'll happily switch.

Two, "It's not supported by cPanel" is valid. By all means, if you are God's gift to server management as well as web design and script development, go right on ahead and run your own "full featured" servers. However those of us who are busy running customer-centric hosting accounts which have an industry-wide commonly-used control panel, lots of features in the GUI, etc., do have to take into account what software is and is not supported by our control panel developers. Because when things break, we have to go back to cPanel for the fix. If we are running Beta software or things that aren't supported, all we get from cPanel is "sorry, can't help you." Well "Sorry, can't help you" doesn't take care of customers. Their stuff still sits there broken! I get paid for results, not apologies.

Yes, yes, I have bucked know-it-all techs/server admins for years who thought they knew better than the lowly cPanel developers, they liked to compile their own Apache and what-not, and all they would accomplish doing is breaking the control panel and upsetting clients. The key here is to keep the clients happy. Keep their stuff working. Therefore I don't put Beta crap on my production servers. If you want to develop for what we consider fringe technology over here (shown by the number of scripts that vomit on PHP5) then you're right, you're going to have to create and administer your own platform for it. I'm busy catering to people who want the easy-to-use control panel, the features, and the wide-ranging compliance for whatever scripts they want to run. They get that with PHP4. They can't get it with PHP5.

Finally, I don't know what's with the attitude of arrogance where people think they can just demand of their clients where they may or may not get their services, but I have two words for companies that try to pull that sort of crap on me: "Get lost."

Anyway, just a few thoughts from the (apparently) bad side of the tracks.

Finally, I don't know what's with the attitude of arrogance where people think they can just demand of their clients where they may or may not get their services, but I have two words for companies that try to pull that sort of crap on me: "Get lost."

This is nonsensical. If I want to run RT from bestpractical, then I have to find a hosting account that supports perl. It's no good me crying to best practical that my Windows 2K3 host doesn't support it. I'd hardly say bestpractical were being arrogant by requiring perl. In the same vein, if I want to run a product that's written in PHP5, then I need to find a host that supports it. It's not arrogance, it's system requirements for the software I want to run.

Personally, I consider that one of the major contributing factors is that PHP4 and PHP5 do not run simultaneously on apache using mod_php as this makes it more hassle for development migration in smaller shops.

The reason it isn't valid is because PHP has nothing to do with cPanel. cPanel marked it as beta/testing (I don't think they have in a long time) because some scripts broke with it. But cPanel itself had no problem with it and don't provide any support for it.

I guess it's a similar problem to MySQL 4.1.x... if hosts upgrade to that in cPanel they get problems with backups freezing the server and multi-language side-effects, so many just stick with MySQL 4.0.x. Upgrading to PHP 5 will just be a headache, probably far worse than MySQL.

Edit - should also be noted the only versions cPanel servers have for PHP 5 is 5.0.4 and 5.0.5. I use 5.0.4 as my development server locally and it's pretty buggy, have had to write around seemingly random bugs especially in relation to mysql_query... not tried 5.0.5 though.

It depends on what kinds of things you are doing. If you have projects with wide distribution, like commercial software or open source, then you have to consider that the widest available distribution is in PHP 4.

If you have a narrow distribution, for example, in house stuff or clients where you can easily control the PHP version, then PHP 5 is better.

Hosts are running a business, and unless there is a pressing need for them to change what they are doing, well heaven forbid they should actually be meeting the needs of their business with PHP4! Damn them anyway! Come on, guys. Everybody loves a new little toy to play with, but let's get a grip and peek at the larger picture that is conveniently being ignored.

I don't get it -- a little toy? We'll see if you are singing the same tune 6 months from now. The point that was being made was that hosts can technically offer both PHP4 and PHP5 should they so please (ie: it makes business sense). The sentiment you refer to against hosts is directed at those who claim that it is technically infeasible. Heaven forbid that a customer would expect that a competent host can provide PHP5 functionality on top of PHP4 support. That is, not a complete switch of everything from PHP4 but rather, a complementary PHP5 service. I readily admit there may be business reasons for not doing so but I disagree with the earlier sentiment stated in the thread that not having dual PHP4/5 support is somehow the fault of the PHP devs. It is purely a hosting issue.

Originally Posted by baileysemt

Yes, yes, I have bucked know-it-all techs/server admins for years who thought they knew better than the lowly cPanel developers, they liked to compile their own Apache and what-not, and all they would accomplish doing is breaking the control panel and upsetting clients.

ACK. Competent admins wouldn't break your servers and the fact that you speak of them in such low terms makes me wonder. I guess if you are running services for the LCD then building around cPanel makes sense -- but making it the cornerstone of your business? That's quite a dependency, but I don't sit in your seat

My argument stands... there is no motive.
So I write __constructor instead of the actual name of the class? So what?
So I have to write getVar() and setVar() to be OOP instead of public/private.
So I have to write fopen() and then fread(), or just File().... instead of file_get_contents etc...
So the error messages are more detailed.. IT doesn't matter

All these are very trivial advances, and reallly are unimportant. You still haven't given me one reason why I should waste my time learning PHP 5.

All these are very trivial advances, and reallly are unimportant. You still haven't given me one reason why I should waste my time learning PHP 5.

Bit of an oxymoron there. If the advances are trivial It should take no time at all and/or require very little learning if they are infact trivial, as you say. If learning is difficult and time consuming the advances must be more then trivial. Take your pick.

"A nerd who gets contacts
and a trendy hair cut is still a nerd" - Stephen Colbert on Apple Users

Well, actually file_get_contents() is a PHP 4.3 feature, thought file_put_contents() is new in PHP 5.

From my point of view, it really doesn't matter why so many hosts aren't supporting PHP 5. Be it because of technical incompetency, to avoid user confusion, or because it doesn't fit their buisness model, whatever. The main issue is that most hosts, at least most of the ones I've worked, use PHP 4 (and MySQL 4) and there's nothing I can do about it. As a developer, I'd love to see a quick move to PHP and MySQL 5 or 5.1, but it isn't there, obviously.

There are several applications I'd like to make in PHP, but which PHP version do I choose? I can write an app that's compatible in both, but that really means writing a PHP 4 app that doesn't spit up any PHP 5 errors. Writing a PHP 5 app right now would mean targetting a much, much smaller population of users right now, but I think we all know (hope?) that this going to change. So do I create apps for the here and now, or for the coming? How long is PHP 5 going to be and coming, that's REALLY what I'd like to know.

I don't get it -- a little toy? We'll see if you are singing the same tune 6 months from now. The point that was being made was that hosts can technically offer both PHP4 and PHP5 should they so please (ie: it makes business sense).

Yes, a little toy. Just because you guys want to play with the latest and greatest doesn't mean there is a big demand for it on the end-consumer side. From my perspective, dealing with the people who write the checks, they couldn't care less about PHP5. It is important to you guys, yes, but not to the people paying the bills -- the customers. As a customer-centric business, I listen to what my customers tell me they want. They far and away drown out the boys who wanna play with their new scripting language. Sorry.

Will I be singing a different tune in 6 months? Maybe, if the major script developers have come out with new versions which are PHP5-compliant. I think a more reasonable timeline is 12-18 months though. I just don't see that many scripts being ported that quickly. Software development is notoriously slow, and developers tend to overpromise their timelines.

Originally Posted by jayboots

Heaven forbid that a customer would expect that a competent host can provide PHP5 functionality on top of PHP4 support. That is, not a complete switch of everything from PHP4 but rather, a complementary PHP5 service. I readily admit there may be business reasons for not doing so

On the contrary, if there was a whit of demand for it, I'd run it. Fact is, not one customer has requested it. Not one. One guy asked about it, openly explaining he was "curious" about why we ran PHP4 instead of PHP5 because wasn't PHP5 the latest and greatest? He had no idea about how so many scripts were incompatible and got pretty excited when I told him 2 of his scripts would break on PHP5. "You're not switching to it, are you???" LOL... No, I assured him, we weren't and everything would be okay.

Originally Posted by jayboots

but I disagree with the earlier sentiment stated in the thread that not having dual PHP4/5 support is somehow the fault of the PHP devs. It is purely a hosting issue.

Baloney. If I have a reason to run it, as a host, I will. However I don't throw money to the wind just because it's fun to watch the bills blow down the street. Mainstream hosting customers don't need PHP5. When the majority of mainstream scripts actually successfully run on the platform, and people want to run those scripts, you bet I'll offer the service. Until then it is simply a waste of my time and money as the PHP5 server will sit there empty and unused. And why should *I* foot that bill? If you want it that badly, drop me a line and I'll sell you a dedicated server. You can set up whatever you want on it.

What I'm trying to explain is that, unfortunately, though you are a group of bright and committed guys, you are a very small niche market and your needs do not currently reflect those of the mainstream hosting customer. I promise I'm not saying this to be mean, I am just trying to explain the bigger picture. Yes, PHP5 is very important to you. However there are few of you, and your desires don't represent the majority of hosting consumers. (Yet!) I'm sorry, it's the sad truth.

Originally Posted by jayboots

ACK. Competent admins wouldn't break your servers and the fact that you speak of them in such low terms makes me wonder.

This was at one of my past jobs. They were God's gift to server administration -- just ask 'em. Heaven forbid Miss Common Sense over here would have a clue... It's funny in hindsight. It wasn't so funny in the middle of the fallout though. Interestingly nobody liked it much when I said, "I tried to tell you..." Man, those were the days...

OK, anyway, thanks for not flaming me. I'm sorry I was such a chick about this earlier. I don't know many of the technicalities. I am the business lady. I know enough to get a handle on how things work and make educated decisions... I even know enough to work the front lines in tech support. (!) But at the end of the day I am the business lady, and I picked up on this topic because you're discussing what is for us, a business decision. When customers are pissed because their scripts don't work, or they can't run XYZ PHP script because it pukes on PHP5... that seals the deal for me. So long as the customers are footing the bill, I as a host do what I can to meet their needs. Currently, their needs are not PHP5.

I don't actually use PEAR as I don't trust it 100% (like Perl's CPAN), but this one is useful if you need to use a function that's in PHP 5 but for some reason not in PHP 4. I just grab the functions and place them in an include file - they use function_exists() in the code - so when you eventually upgrade to PHP 5, the script will continue to work.

PHP5 has now been out for a fairly long time, and PHP6 is on its way. I know hosts were slow in adopting PHP5 for a long time, but, is it safe to use for commercial applications yet?

I thought of something else I should add: It also depends on who you are marketing to. If your script is likely to be used by people in shared hosting environments, then you might consider using PHP4, since it is far more likely to be what your customers will have access to with their current hosting requirement. But if your product is likely to be used by large sites that often run on VPS or dedicated hosting, then PHP5 probably isn't as much of a problem--since they can install whatever they need.

That's just another thing to consider along with what I said in my previous posts.

get the feeling that the new Zend Framework will push more Hosts to use PHP 5?

That is one of the reasons behind the framework, yes; Modeling a framework on PHP5 makes good business sense as well btw - PHP5 opens up possibilities for business, that are either not possible, or viable (appropriate?) with PHP4.x.

If it takes a determined effort from Zend and co. to push a framework onto the development community in an effort to further promote PHP5 then thats a good thing - if it opens the eyes of some hosts, then good.

Something has to give, and I believe it's down to the hosts for the most part; Clients need to respond more positively so maybe the benifits of this framework if any, will help.

My feeling about my web host upgrading to PHP5 is this. If PHP5 could break any of my sites or force me to do a mess of code changes, I don't want it. If my host wants to upgrade my account to PHP5, then PHP5 had better be 100% backwards compatible to PHP4 and I'd better not have ANY scripts break.

Why aren't hosts upgrading? I think the reason is very clear the bulk of their existing customer base is not demanding it AND they are wary of breaking their customers' sites. I can also appreciate web hosts not wanting to go through the hassle of getting two versions of PHP to work side by side when from what I gather from this thread the PHP developers didn't exactly make it a priority to make sure that it was really easy to get PHP4 and PHP5 run side by side on the SAME instance of Apache.

My feeling about my web host upgrading to PHP5 is this. If PHP5 could break any of my sites or force me to do a mess of code changes, I don't want it. If my host wants to upgrade my account to PHP5, then PHP5 had better be 100% backwards compatible to PHP4 and I'd better not have ANY scripts break.

Why aren't hosts upgrading? I think the reason is very clear the bulk of their existing customer base is not demanding it AND they are wary of breaking their customers' sites. I can also appreciate web hosts not wanting to go through the hassle of getting two versions of PHP to work side by side when from what I gather from this thread the PHP developers didn't exactly make it a priority to make sure that it was really easy to get PHP4 and PHP5 run side by side on the SAME instance of Apache.

This is exactly why we have not upgraded our servers to PHP5. If the demand is there for PHP5 I would set up a dedicated server for that. I have yet to get a single request for PHP5. Unless I have 10 clients wanting PHP5 it wont happen with our hosting company.

These are the reasons for slow adoption of MySQL 5, php 5, ruby on rails. Soon to join them in waiting will be Zend Framework,Parrot and Perl 6.

Web hosts are like car dealerships. There those that have great shop areas with mechanics that can do anything to what is sold and there are those that can only do what the EPA and Safety Commisions tell them they have to do because they have no other knowledge than that of the mechanic that know how to run the one machine they need to stay in business.

The lack of upgrades lies with two businesses the web hosts for not demanding compliance from the hosting software industry. And the hosting software industry who are happy to take the subscription money for doing nothing if there are no demands made upon them to do anything other than support what they already have distributed.

Some large web hosting companies have built their own CPs and have their own R&D. They see it as a must to stay on top. But those that have 50 servers and only a few thousand accounts will just wait. The OSS world waits with them or are slow in getting on with the change because the demand rolls down to them it does not start with them.

Users of OSS need Installatron and DA and CP and if they don't work with php5 then they are stuck.

This thread reminds of when ASP 2.0 and ASP 3.0 were popular. The demand for ASP 3.0 was almost nothing. It just came as an after effect of wanting Windows 2000 IIs5 support. Unfortunately php5 is not so connected to Apache that it has to be installed. It would not make any difference either since Apache 2 is also waiting in line with the other software that hosting companies have not adopted.

My feeling about my web host upgrading to PHP5 is this. If PHP5 could break any of my sites or force me to do a mess of code changes, I don't want it. If my host wants to upgrade my account to PHP5, then PHP5 had better be 100% backwards compatible to PHP4 and I'd better not have ANY scripts break.

The really annoying thing, and proof in my mind that Zend were losing the plot, was the difficulty in writing PHP5 compatible code in PHP4. Even if you use none of the new features, or hide them behind version checks, you will get streams of notices at the very least. With PHP 5.0.5 you are likley to get fatals as well. Things get worse wth each PHP5 version (XML stuff is now mandatory for example).

SimpleTest, which is a fairly small piece of software, took about a day for PHP 4.4 compatibility, and a couple of weeks to get PHP5 compatibility. In fact I still have some problems with PHP 5.0.2, so I'm not there yet . A large codebase of one of my clients took 6 days just to get PHP 4.4 compatibility . The standard here is notice clean, so that the code works on development boxes as well.

Given the magnitude of the work involved in older, PHP3 derived work, I cannot imagine all the old tools wil be upgraded. This means...
1) Finding equivalent tools that are PHP4 and 5 safe, a small set indeed.
2) Waiting for all the hosting accounts to migrate to these alternate tools.
3) Waiing for them to migrate their own code to both 4 and 5 compatibility (a tricky technical task).
4) Only then switching to PHP5.
5) After all that, accounts can make use of PHP5 libraries and syntax, finally getting some small benefit.

That's a long hall for a small gain.

I think the shift is going to happen by brute force. Component frameworks and PEAR modules will become PHP5.1 only. The "clique" just don't care about PHP4, because no one mentions it at conferences. This means that all new software will be forced into PHP5.1 (non PHP4 compatible) or will face out of date libraries and dependencies. Most PHP4 apps will be abandoned and replaced with 5.1+ versions only, because of the cost of maintaining two versions. Eventually the weight of all of this will force a sudden and catastrophic shift.

Rather than migrate kicking and screaming to PHP5, some will migrate to Ruby, or the rapidly slimming Java.

Let's face it ... the main reason to switch to PHP5 is because it allows you to do more interesting things with objects: especially passing object by handles which eliminates a bunch of workarounds. And as this forum frequently laments and debates, the majority of PHP developers use Structured Programming not OOP. Even many of the core developers seem to prefer Structured or pseudo-OOP. So the people who are interested in PHP5 are pretty much the people who hang around here or programmers developing stuff internally for companies who don't rely on hosting and use OOP. The "market" is obviously doing what it is doing based on the prevailing forces, and so here we are.

Where (or whether) it is interesting is that PHP6 will supposedly be out this year. For an incredible spin on what most consider to be a screwed-up situation see the News section on Zend's PR machine at work:

Getting back to the original question of whether to build an app in PHP4 or PHP5, this is how I would look at it. If it is going to be a major commercial app that was going to be supported for a long time to come, I would build it in PHP5. The reason is simple. Even though the uptake of PHP5 by web hosts is very small at this point in time, eventually PHP4 will be cast off into the scrapheap of legacy code. If one programs something new in PHP4 today, they will be forced to upgrade it to PHP5 eventually anyways. By starting in PHP5, one is avoiding one generation of forced upgrades.

Sure this would limit web hosting options in the short run, but eventually the options would broaden.

I would qualify this reasoning by saying if PHP6 is just around the bend it is very concievable that the bulk of the industry would skip over PHP5 and go from PHP4 to PHP6, so the strategy I laid out above really wouldn't save any effort.

I design a number of applications, and I do as KLB says. I build everything in PHP5. It isn't too hard to then go and test it in PHP4. As long as you don't use any of the new changes it works fine. Of course you really aren't taking advantage of PHP5's features, but oh well really. There isn't much that you can do about it.

My host allows us to compile PHP5 under our account. I haven't done it yet as I really don't want all my files to have .php5 as an extension, it would mess with my search engine parts (even though I use a lot of mod_rewrite for a folder look).

I think that host should start offering clients a server with PHP5 that they can move to. Sadly my host doesn't do that. I think they could also tell customers like six months ahead of time that they are going to upgrade the servers and clients should take precautions, and they could offer an additional server if they client really wants to keep PHP4.

I think cPanel is what is holding. My host said they haven't upgraded because cPanel hasn't made an official okay and release with PHP5. It's quite sad, but I'm living with it.