I am usually fascinated by articles defending PHP and the arguments being used. Quite often authors of these types of articles don't mention what experience they have with other languages. Personally I find it hard to imagine that somebody would know either Python or Ruby, and PHP at a high level and still prefer PHP.

So if anyone fits this description, I would be interested in hearing why you prefer PHP to either of these languages.

  • 5
    I don't like PHP at all, it's a fugly language IMO, but I have to admit that every el-cheapo-webhoster offers PHP support for something like $3,- p.m., while Python typically requires a more expensive package. – user281377 Dec 1 '10 at 9:03

Yes, I flat out prefer the C-style syntax in PHP over Python or Ruby (perhaps over Ruby less so). I could do without the sigils ($) for variables in PHP, though.

I've never had the problems with PHP that a lot of people seem to have. If you develop your applications as applications, and not individual peieces that get inserted into web pages by intermingling HTML and PHP, PHP is not that much different from other langauges. And the library support and available online resources are huge. People moan about 'inconsistent' function parameters and such, but thats never been a huge hinderance to me.

PHP does give you a lot of rope to hang yourself, though, if you arent a disciplined programmer. You can get yourself into a lot of trouble if you start using little PHP tricks all over the place (variable variables, using include() as function calls, etc).

| improve this answer | |
  • 1
    +1, and I find the "inconsistent" naming to aid in remembering the various functions – Izkata Jan 6 '12 at 22:48

Our company still prefers PHP for a few simple reasons:

  • Easy to scale to medium sized deployments. No need for proxy servers, caches, etc., PHP is fairly efficient with very little effort. Also trivial to set up for most developers.
  • Developers are cheap and abundant. This is especially handy for enterprise shops like ours where we're solving relatively narrow problems. This makes PHP profitable for vertical style products.
  • Easy to train the average developer. We've converted Java, C, and C++ programmers to PHP with minimal effort. Python and Ruby are excellent languages, but they take a bit more thinking for average developers to grok (in our experience).

Now for me personally (versus my employer), I prefer Ruby + Rails for web development and Python for back-end tools (like mini servers, etc.). These two languages are interchangeably great, but I've traditionally used them for those two purposes.

And looking to the future, JavaScript on the server is gaining mojo, especially in places where I've traditionally used Python (mini servers, etc.).

| improve this answer | |

I consider time to ship and portability. In the cases where I actually have to do some kind of web development, it usually means I'm writing some kind of control panel.

It is just stupidly easy for me to put something together using Code Igniter, I get it done quickly and get it out the door. Additionally, I'm quite sure that the app will 'just work' on many web servers.

So I guess for me, it's not a preference over the language itself, but how quickly I can say "Yess boss, it's done .. " I do want to spend some 'quality' time with Django .. and perhaps it will become my preference in the future.

While I do like Ruby, I realize that I am not nearly experienced enough to use it safely.

I also don't consider something 'inferior' just because it is written in a certain language. If the problem being solved fits well into the language's domain, what's the problem?

| improve this answer | |
  • 1
    But this sounds like you can get things done quickly with it because you know it better than you do your Rails or Django. My question was more about if you know PHP and one of the "other" languages just as well, is there still anyone who prefers PHP for some reason. – Sam Dec 1 '10 at 9:46

IMO the real advantage of PHP is the ease of finding team members. From my experience, Python and Ruby developers are harder to find and cost more.

However, from a development standpoint, I prefer Python.

| improve this answer | |
  • This is common, but it also means that being a Python programmer is arguably better for your career. – user16764 Jul 5 '13 at 21:03

From a language semantics point of view, I absolutely prefer Python. (Disclaimer: not yet using it for really long.)

However PHP is way more useful for building web apps. And I would blatantly describe it as suitable for that. The language itself suffers from serious misdesigns (and I just accidentially mention the new namespace syntax in brackets here), and many PHP programmers are prone to cargo cult programming. Yet, the vast amount of libraries tailored for webdevelopment makes it the better choice for what I'm doing.

As example (my favourite example), none of the Python HTTP libraries supports content encoding correctly out of the box. Whereas writing Gtk/GUI apps would is a joke in PHP in comparison to Python. So it really comes down to what sort of applications people are building. The language preference is probably just that.

| improve this answer | |
  • 1
    Python HTTP libraries? python-requests does indeed handle content encoding correctly. Out of the box too. – user16764 Jul 5 '13 at 20:38

I know both Ruby and Python far, far better than I do PHP, and I prefer PHP for the incredibly mundane web programming tasks I occasionally have to do. The server supports it, I can hack together solutions without having any idea why what I'm doing is working, and I can test it easily using a MAMP server with minimal setup. PHP provides quick and dirty solutions to simple problems.*

  • This is a statement of personal experience, not a value judgement about any language, designer, or developer.
| improve this answer | |
  • "I prefer PHP for the incredibly mundane web programming tasks I occasionally have to do." - do you have some examples? – ocodo Dec 13 '10 at 3:56
  • Sure. I use PHP to build brochure websites. If several pages share the same block of HTML, like a sidebar, header, or footer, PHP is the simple solution for avoiding cutting and pasting a bunch of code. I occasionally use platforms like Drupal for very, very simple ecommerce sites, which requires some PHP hackage to customize things. An example of the latter: emptyhandsdojo.com – philosodad Dec 20 '10 at 13:17

The only thing I would use PHP for is web programming. But it is the only thing I would use for web programming.

I don't really like OOP so python and ruby really have no appeal for me. I learned a lot from my 2 years of professional full-time Rails and it changed the way I write PHP. I suspect most PHP programmers would my PHP code. And the aspect I like best about Django (just from ready the introduction in '08) is the template engine and we have Smarty, so…

So… yes I went back to PHP. And I like it! I still cringe a little when I have to type out array( instead of [ but on the other hand I love that arrays are always ordered-maps. That is just plain handy, at least for web type programming.

(I love javascript bestest of all, could you imagine if there was some baller server-side run-time?!)

| improve this answer | |
  • 2
    You'll be looking for Node.js. nodejs.org – ocodo Dec 13 '10 at 3:58
  • I suspect there is an eaten verb in "I suspect most PHP programmers would <missing verb> my PHP code"; I'm just curious. ;) – Sony Santos Feb 4 '15 at 13:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.