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.

Why php?

I notice soooo many people using php. Why? I'm into JSPs/Servlets and ASP.NET/C# myself. I enjoy each platform. I'm curious as to why PHP is such a hit. I can think of one easy reason, most every web host in the world supports it with mysql. Isn't php just a bunch of scripts in a page (ie: original asp)?

That's one reason I started with Java myself. Free is always good. Now that I've opened myself to consulting work, clients are willing to pay for items such as VS.NET and SQL Server. Hell, I'm happy with JSPs/Servlets, Apache/Tomcat, and MySQL. Great combo with little to no cost.

You use the tools you have available, and PHP being available on most (Apache) servers is probably a major reason for it's popularity.

These days, though, ASP, JSP, or PHP - or even Perl or Python - are available for just about any platform. Use the one that's comfortable for you. I use PHP because I know it inside and out and don't need to learn anything, but I'm sure I could accomplish the same things in another language if I needed to.

"I can think of one easy reason, most every web host in the world supports it with mysql"

cheap hosting is perhaps a side effect, not the cause of PHP's current popularity.

PHP had a rapid rise to popularity not because it had a good hosting base nor because it was free (i.e. PERL is free as well) but because it was an excellent solution to many web-scripters needs , much easier than PERL whilst at least as powerful as ASP (I am talking PHP3 days here btw)

My first experiences with PHP were with postgreSQL or MSQL as the DB as MySQL hosting was pretty slim at that point.

Developing smaller applications in PHP is a breeze compared to JSP/servlets + its faster than JSP/servlets no matter how fast JSP should be ..cos its slow regardless, + its far easier without losing any raw grunt etc etc.

With essentials that came with PHP4 (session support!) many found that PHP could not only handle those small to medium sites but much larger ones as well , MySQL is only 1 of the databases that PHP supports and the fact it can talk to Oracle and its ilk made it a useful tool in larger more complex applications ... that said MySQL itself still continues to perform despite all the things that are supposed to be wrong with it.

PHP5 with full OOP support should ensure PHP's continuing rise , yes its getting even better , very soon

Isn't php just a bunch of scripts in a page (ie: original asp)?

checkout class choice extends options{}
if thats how you want to code it yes , if not then no , its up to the coder (I won't go to far into this as .NET'ters may have an attack of the vapours )

Obviously coming from another language/environment altogether you have a severe lack of PHP understanding.

This I can understand, though I would say that PHP if a lot lot more than simply 'a bunch of scripts in pages'.

Why do I use it ? Simple really -

1) It's open source and under constant developement from any number of angles
2) It's a powerful scripting language offering just about any functionality that you can throw at it in terms of application development
3) It's easy to learn and develop for
4) It uses the Apache Web Server - for a lot of people this is the one real reason why they develop for PHP alone.
5) With PHP5 about to be released as a stable language later this year, it's heading for the big time - far far more powerful than what CF has to offer at the moment IMO
6) .NET is a closed Microsoft technology; where is your freedom to innovate I ask ?

You could say the same for Java though.
7) Freely available scripts and forums with an incredible feeling of community openness for PHP.

Really, developers use PHP today in large numbers because it can provide a quick (relatively speaking compared to other languages) solution with the minimum amount of headache - there is an incredable community spirit as I stated above for PHP that apart from Java, no other language has this for developers.

So .Net ? No thanks, as I'm going to continue to use the most powerful scripting language available to mankind today.

If you're into Java/Servlets then PHP is a very logical step, as it has the ability to integrate with Java components. Its very possible to use Servlets for the 'core' of your coding, and use PHP to form the user interface. Thus gaining points from the sheer speed of PHP, without losing the power of Java.

The reason PHP is more popular over more advanced programming frameworks, like Java or .NET (and more recently ColdFusion, in it's MX variant) is that it's so extremely available on many levels:

1. It's VERY easy to learn.

2. It has an fabulous developer community (which means hogloads of tutorials, forums, existing code and extensions)

3. PHP/mySQL hosting is very cheap
This is not so much due to PHP itself being free, but due to the fact that it's "default" environment (Linux, Apache, mySQL) is a free OS, a free Web server, and a free DB serve. Java and .NET generally requires more expensive stuff to run optimally. With that said, I resent hyperboliks notion that it's more expensive to develop .NET than PHP, which is untrue - all the needed development tools are provided for free by Microsoft, except for Windows itself.

Originally Posted by torrent

- powerful
- fast

I don't really think those two holds water as primary reasons why people choose PHP, as both .NET and Java (and therefore ColdFusion MX) are (arguably) both faster and more powerful.

6) .NET is a closed Microsoft technology; where is your freedom to innovate I ask ?

I don't really think those two holds water as primary reasons why people choose PHP, as both .NET and Java (and therefore ColdFusion MX) are (arguably) both faster and more powerful.

Okay, but back in the real world... We have used Java, PHP, and ASP technologies in a commercial environment. I personally also develop (to an admittedly lesser extent) in CFMX. If you truly believe Java and ASP are "arguably" faster than PHP then you need to take a look at using performance monitoring tools to assess processor load, and memory/paging requirements of them all. We have done this internally in a 6 month, fairly exhaustive, load intensive trial. Our findings were that Java created a large server overhead, especially with regards to memory usage. However, ways were implemented to optimise this and eventually we got, what we considered, to be reasonable performance under load from it. As for ASP, the fact that it is constantly context switching in and out of the HTML parser in order to select the compiler, means by its very nature that it will be slower than PHP in execution (not to mention more resource intensive on the server). This proved to be the case. ASP was, in our tests, considerably slower than PHP. We didn't use .NET btw.

As for Coldfusion, well, I found that CFMX was fabulous for doing the quick and easy tasks as it has some pretty neat functions. However, when you wanted to do something a little more complex then it became a bit of a trial. For example, regular expression support is abysmal, as is developing socket based interfaces (a common requirement for us). Speed wise it was quite impressive, bettering PHP in some areas, but not in others. Overall though we were very unimpressed with Macromedia's support and questionable product direction.

As an organisation, we took a corporate decision to use Java and PHP where web management tools were being created (for a particular bespoke product we supply), depending on what the size, complexity, and nature of the tool implementation would be. It helped also that PHP can call and use Java objects and methods.

I'd be interested to hear what evidence you based your views on.

Oh, if anyone is interested we also ran a load and destruction test study against Oracle, MySQL, local HSAM, and local ISAM databases (didn't have the means at the time to include MS SQLServer).

You are definetly more experienced than me, and if you have done first-hand testing, it's more valid than my views, which are mostly based on benchmarks that I have seen. It's unfortunate that you did not include .NET in your testing, as I'm yet to see any decent comparison between it and PHP.

What was your conclusion on Java and PHP, speed wise? Is PHP faster, and if so, by how much?

Oh, and doesn't CFMX run on top of Java nowadays, or something like that?

edit- also, for the record, I never said that ASP was faster than PHP. None of the testing I have seen have indicated that at all.

Which container/app server did you use to test your Java applications? WebLogic? J2EE RI? Or just Apache linked with Tomcat?

How did you reconcile a fair benchmark test when Java app servers are built to scale for large complex applications, but are overkill for simple web scripts, with PHP's speed in web scripting?

I agree that Java app servers have large memory consumption, but they do much more. That said, this is after all a web development forum so little would people here be compelled to switch to Java server programming. If anyone is interested in being an enterprise developer though, J2EE and .NET are the 2 bandwagons you should jump on. PHP doesn't cut it yet, though integration with Java is a big step.

Regarding the exact details of the testing environments, I would have to find that out as I was not directly involved with actual trials. My involvement came when I (as a Senior Project Manager) was scoping out the work involved for a project in the Middle East, I read a report on which technologies are being endorsed by our company for web development purposes. The concensus was, as Redemption summised, that Java was the way to go when needing to follow good MVC methodology and producing an Enterprise wide solution and that PHP was deemed (by our company at least) the way to go when requiring RAD. PHP5 may address some of PHP's short comings with regards with to Enterprise solutions, although I still doubt it will be a match for J2EE in that environment.

I'm not sure we'd ever get round to testing against .NET as we pretty much require platform independent code (another thing that went against ASP as Chillisoft doesn't cut the mustard). Can .NET run on non-MS Windows servers? I don't think it can (my knowledge of .NET is extremely limited)?

I'm not sure we'd ever get round to testing against .NET as we pretty much require platform independent code (another thing that went against ASP as Chillisoft doesn't cut the mustard). Can .NET run on non-MS Windows servers? I don't think it can (my knowledge of .NET is extremely limited)?

Ximian is currently working on the Mono Project, which is essentially .NET for Linux. They are making marvelous progress, but I'm not sure whether it is ready for production yet.

There is the Mono project which is, and I quote, "is an open development initiative sponsored by Ximian that is working to develop an open source, Unix version of the Microsoft .NET development platform."

I have no experience with it, nor much experience with .NET itself so I can't comment on it.

While torrent's opinion may be based on experience, most of his list is contained in other languages. Sure, they are reasons to pick PHP, but most of his short list aren't reasons to pick PHP over any other language.

I still love the fact that "free" is thrown in there. Some people mock my viewpoint that free isn't free. Well, this week we gave Linux a shot. We needed to put a new firewall in, so were going to need to pay no matter what, perfect opportunity to give it a shot.

Got a new server, got Linux installed and then gave the team 20-40 hours to do configuration and tweaking. At the 40 hour mark it would have been cheaper to buy a high-end firewall solution. At the 100 hour mark it would have been cheaper to buy a firewall appliance.

The team, yesterday, hit the 100 hour mark and it still isn't working properly. Certainly part of this is due to me giving them the freedom to fail (which is important since one of the developers is a Linux "advocate" and he never believed me that Linux isn't always cheaper).

That said, the original poster is coming from a .NET environment, so others should try and give him reasons why PHP is a benefit to him where he's at. He's not coming from an ASP or CFM environment so much, and so needs to be given advantages over Java and .NET. Don't worry, there are those advantages, the main one being that by and large PHP can be quicker to develop for on smaller projects and websites.

J

ps: pfft @ PHP encouraging RAD, it encourages exactly the opposite by the fact that it still allows old, antiquated and useless code while "enabling" new advances such as OOP. Having these as an option means new developers will almost always pick the simplest route, which is always the dirtiest one.

Got a new server, got Linux installed and then gave the team 20-40 hours to do configuration and tweaking. At the 40 hour mark it would have been cheaper to buy a high-end firewall solution. At the 100 hour mark it would have been cheaper to buy a firewall appliance.

Maybe you should employ people that know what they're doing? - just a thought.

ps: pfft @ PHP encouraging RAD, it encourages exactly the opposite by the fact that it still allows old, antiquated and useless code while "enabling" new advances such as OOP. Having these as an option means new developers will almost always pick the simplest route, which is always the dirtiest one.

I agree, with the word being thrown around, I think it should be made clear what RAD (Rapid Application Development) means. I picked this up from a site (don't worry, it isn't copyrighted content)

RAD (rapid application development) is a concept that products can be developed faster and of higher quality through:

* Gathering requirements using workshops or focus groups
* Prototyping and early, reiterative user testing of designs
* The re-use of software components
* A rigidly paced schedule that defers design improvements to the next product version
* Less formality in reviews and other team communication

In PHP, apps are developed faster, yes, but not often of higher quality.

I would say that typically the "quality" of the code is down to the "quality" of the developer. In any language. Choose a strong developer who understands good-practice methodologies (such as MVC), and you will produce good quality code. Any poor workman can blame his tools (or his employees)

I would say that typically the "quality" of the code is down to the "quality" of the developer. In any language. Choose a strong developer who understands good-practice methodologies (such as MVC), and you will produce good quality code. Any poor workman can blame his tools (or his employees)

I think what Jeremy (and I actually) are getting at is that some tools are better than others. With PHP, it is difficult to have good practices (evident in many projects). With Java and .NET, a certain foundation is there, though of course it can be misused.

With the Linux firewall, it would be more difficult to setup and cost a company in terms of the time used (which is money). With a high-end firewall solution, you often get a solid product and support, but if you don't have good practices, the firewall might as well not be there.

I'm sorry, which part of the story infers that the team were without skills or not up to the task?

Your post refers to the predictable age old Microsoft quote of "Linux is free if your time is worth nothing" This is all a bit boring and old fashioned now, the fact of the matter is the software is free and a lot of the time better than the paid for competition. Why Microsoft people have a problem with free software is beyond me and I can only assume they feel threatened by it. You cannot seriously say Linux isn’t free because it took your workers over 100 hrs to configure. If that is the norm I cannot understand why so many businesses use Linux as a solution and more are moving. If you are going to mention time being wasted when configuring Linux it’s only fair we mention all the time that gets wasted when Windows – crashes, needs re-booting, sorting out security breaches/ problems and numerous other bugs that come standard with all of Microsoft’s products. And of course Windows isn’t free and isn’t Open Source.

On the cost of Linux (and it's general ascent) one of the most level headed pieces I've read is thanks to the Economist here.

As to why PHP? There are many reasons ranging from ease of use, flexibility, availability, the energy of the community (i.e. massive quantities of free code) and even "ethical" reasons. One nice quote I've heard from here is;

Because PHP is built by developers for developers, rather than by marketers for BDMs, I know I'm generally going to get the best solution to solve my problem with minimal overhead (redundant BS code).

Otherwise methinks there's a "showdown" coming eventually between loosely and strongly typed languages which will ultimately see companies accepting new approaches to software development. It's worth remembering that right now practically all loosely typed interpreted languages of note (i.e. Perl, Python, PHP and Ruby) are Open Source projects without the commercial backing to "force" them into board room meetings. Instinctively though, anyone who's spent a decent amount of time with any of those knows the benefits over strongly typed languages, even if they can't name them.