The PHP Singularity

June 29, 2012

Look at this incredible thing Ian Baker created. Look at it!

The PHP hammer

What you're seeing is not Photoshopped. This is an actual photo of a real world, honest to God double-clawed hammer. Such a thing exists. Isn't that amazing? And also, perhaps, a little disturbing?

That wondrous hammer is a delightful real-world acknowledgement of the epic blog entry PHP: A Fractal of Bad Design.

I can’t even say what’s wrong with PHP, because – okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

Remember the immediate visceral reaction you had to the double-clawed hammer? That's exactly the reaction most sane programmers have to their first encounter with the web programming language PHP.

This has been going on for years. I published my contribution to the genre in 2008 with PHP Sucks, But It Doesn't Matter.

I'm no language elitist, but language design is hard. There's a reason that some of the most famous computer scientists in the world are also language designers. And it's a crying shame none of them ever had the opportunity to work on PHP. From what I've seen of it, PHP isn't so much a language as a random collection of arbitrary stuff, a virtual explosion at the keyword and function factory. Bear in mind this is coming from a guy who was weaned on BASIC, a language that gets about as much respect as Rodney Dangerfield. So I am not unfamiliar with the genre.

Except now it's 2012, and fellow programmers are still writing long screeds bemoaning the awfulness of PHP!

What's depressing is not that PHP is horribly designed. Does anyone even dispute that PHP is the worst designed mainstream "language" to blight our craft in decades? What's truly depressing is that so little has changed. Just one year ago, legendary hacker Jamie Zawinski had this to say about PHP:

I used to think that PHP was the biggest, stinkiest dump that the computer industry had taken on my life in a decade. Then I started needing to do things that could only be accomplished in AppleScript.

Is PHP so broken as to be unworkable? No. Clearly not. The great crime of PHP is its utter banality. Its continued propularity is living proof that quality is irrelevant; cheap and popular and everywhere always wins. PHP is the Nickelback of programming languages. And, yes, out of frustration with the status quo I may have recently referred to Rasmus Lerdorf, the father of PHP, as history's greatest monster. I've told myself a million times to stop exaggerating.

The hammer metaphor is apt, because at its core, this is about proper tooling. As presciently noted by Alex Papadimoulis:

A client has asked me to build and install a custom shelving system. I'm at the point where I need to nail it, but I'm not sure what to use to pound the nails in. Should I use an old shoe or a glass bottle?

How would you answer the question?

  1. It depends. If you are looking to pound a small (20lb) nail in something like drywall, you'll find it much easier to use the bottle, especially if the shoe is dirty. However, if you are trying to drive a heavy nail into some wood, go with the shoe: the bottle will shatter in your hand.

  2. There is something fundamentally wrong with the way you are building; you need to use real tools. Yes, it may involve a trip to the toolbox (or even to the hardware store), but doing it the right way is going to save a lot of time, money, and aggravation through the lifecycle of your product. You need to stop building things for money until you understand the basics of construction.
What we ought to be talking about is not how terrible PHP is – although its continued terribleness is a particularly damning indictment – but how we programmers can culturally displace a deeply flawed tool with a better one. How do we encourage new programmers to avoid picking up the double clawed hammer in favor of, well, a regular hammer?

This is not an abstract, academic concern to me. I'm starting a new open source web project with the goal of making the code as freely and easily runnable to the world as possible. Despite the serious problems with PHP, I was forced to consider it. If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option. If that doesn't scare you, then check your pulse, because you might be dead.

Everything goes with PHP sauce! Including crushing depression.

Therefore, I'd like to submit a humble suggestion to my fellow programmers. The next time you feel the urge to write Yet Another Epic Critique of PHP, consider that:

  1. We get it already. PHP is horrible, but it's used everywhere. Guess what? It was just as horrible in 2008. And 2005. And 2002. There's a pattern here, but it's subtle. You have to look very closely to see it. On second thought, never mind. You're probably not smart enough to figure it out.

  2. The best way to combat something as pervasively and institutionally awful as PHP is not to point out all its (many, many, many) faults, but to build compelling alternatives and make sure these alternatives are equally pervasive, as easy to set up and use as possible.

We've got a long way to go. One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

From my perspective, the point of all these "PHP is broken" rants is not just to complain, but to help educate and potentially warn off new coders starting new codebases. Some fine, even historic work has been done in PHP despite the madness, unquestionably. But now we need to work together to fix what is broken. The best way to fix the PHP problem at this point is to make the alternatives so outstanding that the choice of the better hammer becomes obvious.

That's the PHP Singularity I'm hoping for. I'm trying like hell to do my part to make it happen. How about you?

[advertisement] How are you showing off your awesome? Create a Stack Overflow Careers profile and show off all of your hard work from Stack Overflow, Github, and virtually every other coding site. Who knows, you might even get recruited for a great new position!
Posted by Jeff Atwood
213 Comments

So, as a person looking to learn a language for the web, what should it be?

Jon Reese on June 29, 2012 2:01 PM

As some have already said: throwing PHP out completely is like throwing out the baby with the bathwater. Why not build a library that makes PHP less sucky, similar to jQuery?

Shaun Elliott on June 29, 2012 2:13 PM

PHP has its purpose which is developing simple sites fast. Python and Scala can do that too but they are much more sophisticated. Scala might one day compete with Java in the enterprise world. Hybrid languages on JVM are very interesting.

On the front-end side, all can be done with JavaScript much nicer while having HTML completely separate. If you have a nice event-driven or service-oriented backend which responds to your Ajax calls, what the hell would you need the PHP for? The world is changing, I personally prefer to adapt to the change and not get used to mediocracy of hacking code fast.

Esfandiar on June 29, 2012 2:23 PM

Nah, I like PHP. Thanks, though!

Pbyosh on June 29, 2012 2:56 PM

Being a Delphi programmer with a fair knowledge of C and C++ and able to put together a SQL script, PHP was a shock to me system. My applications is mostly business orientated with integration of fingerprint readers etc. and I want to port it to the web and mobile. PHP stopped me dead in my tract. Because its unreadable from my point of view and I have not control over the hardware. So I am watching this blog for alternatives!

Cornie on June 29, 2012 3:55 PM

One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

SHUT UP AND TAKE MY MONEY.

Brant on June 29, 2012 4:33 PM

I'm going to post my 2 cents.

I started on Perl and switched to PHP because Perl wasn't threadsafe. PHP worked just fine threaded, but ultimately php-fpm became standard, to get PHP out of the memory space of the web server and make it independant.

Much of the crying about PHP has to do with it being a cPanel out-of-the-box install and nothing more. For example, out of the box there is no opcode cache, and cheap hosts don't set the opcode cache large enough to actually get a good hit rate for Wordpress (which requires more than 56MB to function) On top of the RAM requirement (which can require 128MB just to do one thing.)

Wordpress and Mediawiki are some of the most obnoxiously programmed PHP applications in use, yet they are the most popular.

If someone wants to come up with a winning replacement for PHP, come up with a new language that automatically works in threads. So far nobody has done this in an elegant and easy to understand way. Hell most Apache installs still use inefficient pre-fork because that's just what most linux defaults are.

Kisai on June 29, 2012 5:01 PM

There's nothing wrong with pointing out the obvious. However PHP complaints from high profile coders have some side effects. It's not just how the language grew, but the community took some defects.

Recurring rants as this incur some overcompensating on behalf of the php.net developers. Given time they'll "enhance" the language, similarly questionable as the original bit. For example PHP5 brought some overdue simplifications, but they also half-assed access modifiers to make it "more object-oriented". They didn't understand the usage origin, nor read past the first syntax chapter of C++ for dummies.

Likewise PHP 5.3 with the namespace syntax. It's the result of rushing features in because of language bickering. And it doesn't stop there. The shitty backslashes are now used by vast majorities of developers for creating taxonomies, not for resolving identifiers. A lesson well understood in Python, but still to be learned in PHP land. But by then a dozen new idiosyncrasies will have been introduced.

Their development model doesn't sustain the widespread usage and desires for improval. And pointing out the problems with that only adds to that spiral of doom. There are alternatives now with Quercus etc., but they lack the community support and self-reliance.

mario on June 29, 2012 5:50 PM

Hate it as much as you want - it's not as bad as people make it out to be. It really isn't. Here's the solution to your woes:

Security (Blanket) through Obscurity. Take all the inconsistent functions and hide it all behind objects. Ta-da: You now have an object oriented thing to work with, exceptions and all, and at that point it isn't bad. Or, download one of the half dozen or so good frameworks and it's all done for you.

Granted, you shouldn't have to do that, but there you go. PHP has its blemishes, but it's not THAT bad. It seems to me that if PHP had a "function consistency" then most complaints would disappear overnight. I still hear people complaining about broken features that have been obsoleted YEARS ago, yet they still bemoan them as if they has just been pushed into recent releases.

Side note: Complaining about the php.ini that you don't even need to touch 95% of the time? That's really weak. REALLY weak.

You might as well rant about MySQL as well - it's the PHP of databases, and yet I see it being used everywhere with minimal complaint.

Would I rather be writing stuff in Python? Sure. It's nicer. Faster. But quite frankly the documentation sucks compared to PHP, and and the people in the community are far more standoff-ish than the PHP community. No offense to the nice guys I have run across - I've found some nice people out there - but by and large

If you really think that there is a better product out there, then why isn't it on every single crappy ass web host in the world? If it isn't as easy to install and manage then you've already lost. Sorry.

I really do hope that Python manages to get to that level of simplicity. It's nice, cleaner, and has some great features (despite the funky spacing requirement, but I can live with it) but until then: stop bitching and HTFU or do something about it.

AlexStormwing on June 29, 2012 7:23 PM

A few people above have hit the nail on the head here. Shish2k is one. I'd like to add a few additional points.

  1. Cheap, shared hosting doesn't come with shell access. Any language and/or framework that requires shell access to deploy is dead in the water.
  2. By proxy, basically any language that has an elaborate reusable component library (i.e. gems, eggs, cpan) is pretty much dead in the water as well, unless there's a *really* straightforward way to bundle the libraries with your app and have them require zero installation or existing libraries.
  3. Packaged component library systems like RubyGems and Python Eggs are hell for newbie developers.
  4. "import" / "require" / "use". Fucks sakes, it's 2012. Why do we still need to do this shit?
  5. Compiling. Bye bye Java, C#, and basically all other compiled languages. You might be awesome in your own right (C#), but it's just too much work and requires too much knowledge about toolchains.

The second and third points sounds backward, but half the time the package systems:

  • Don't work nicely on Windows (if at all)
  • Have complex interactions with system vs app installations
  • ...and thus launch into dependency hell
  • Require a lot more knowledge about the underlying system to use properly than a new developer wants to learn

For developers familiar with the environment, these systems (mostly) work well. But for devs (even reasonably experienced ones) learning, it's a massive hurdle - and given that they're relied upon so much, it's another "dead in the water" call for the "better" languages. And it's a *gigantic* hurdle for shared hosting deployments.

PHP doesn't really have this problem - so much shit is bundled with the runtime installation itself, very few developers need anything that requires PECL, and PEAR is a) pure PHP, so less of an issue, but more importantly b) kinda shit most of the time, so noone bothers to use it.

So - to get whatever language system we to actually work, here's what we need:

  • Packaging system:
    • That's done developer-side only. No commands to run on the server.
    • Native code only - no compilation or dependency requirements outside this system itself
    • Packages download as source code into your local application tree, load automatically without importing in your code, and don't require *any* system configuration (env vars etc)
  • Language and runtime:
    • Simple syntax that's readable. A subset of Python would be fine, Ruby might be a little... esoteric. PHP's existing syntax is actually surprisingly good in this regard, save for all the dollar signs.
    • Environment needs to be well-standardised and VERY well featured - stuff like SQL database libraries, gdlib, XML, JSON, DOM etc need to be packaged as first class citizen libraries, and expected to be installed by default
    • The above libraries need to load themselves dynamically without any include() or require or use or import statements. This pretty much means the language needs a very strict and very simple namespacing system.
  • Slow-moving target. Python2.x vs Python3 will cause issues for years. Ruby's release speed causes big issues with old gems etc.

Basically, this is a very difficult task. And, there's nothing out there already (that I'm aware of) that does even half this at all well.

Keith h on June 29, 2012 8:12 PM

Python or Lua would both be reasonable alternative choices. Both are "real" programming languages, which have already been used for CGI scripting. Lua has the edge over Python in performance, but Python is more popular and has a (much) bigger standard library.

Max Eliaser on June 29, 2012 9:13 PM

I'm surprised no one mentioned Steve Huffman's course on Udacity*. Simply point an aspiring web developer there, and many will be hooked on Python web developing for life.

*http://www.udacity.com/overview/Course/cs253

Roman Levin on June 30, 2012 12:20 AM

Personally I put my hand up for JavaScript as the obvious alternative (think Node.js). I know such a suggestion would create a look of horror on many a programmer's face - but I'm sure this more to do with JavaScript not being Java, having the word "script" in its name and weak typing not giving the IDE's much help. But the upside is we can stop writing in two different languages on the frontend and backend

Steve McArthur on June 30, 2012 4:29 AM

OK very simple relies on 5 basic lines of PHP and allows you to import PHP functions but has any one tried XML XSL as a blogging platform? No it does not make you look cool or get your whites whiter but the PHP you do use is now simple and straight forward. I use it for blogish type code all the time.

12mail20 on June 30, 2012 4:49 PM

OK here is a analogy that fits: PHP is like a piece of Quartersawn Oak. One craftsmen makes a piece of Stickley furniture. The wood worker at home with an identical piece of wood makes ashtrays.

But since we have far more cigarette smokers than furniture collectors you see many more ashtrays. PHP needs more craftsmen.

12mail20 on June 30, 2012 5:29 PM

Keith h,

You do know PHP has include, include_once, require, and require_once, and even use, right?

Distros also like to ship PHP in pieces, so you wind up installing more than the core language to actually use it. If you build from source, you have to install all the dependencies for each of the included libraries, or it doesn't get built. I'd imagine "cheap, shared hosting" has already taken care of this, so maybe you've never had to install these packages yourself. Someone had to.

I'll also freely admit to knowing almost nothing about Microsoft's compiler toolchain, yet I've managed to write C++ and C# on Windows without this being a problem. I've written plenty of Java, too, without having to care how the compiler gets invoked. This isn't the issue you think it is.

If the chief complaint about non-PHP languages is "newbies have to learn too much to use them," let me suggest you have to learn a lot of things to use PHP well too. If you don't like thinking and learning, I suggest another career.

LnxPrgr3 on June 30, 2012 5:54 PM

One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

Tell us more about this next project !!!
Have you started it yet ? What's the progress so far ?
Is this project backed by StackExchange (the company) ?
How can we contribute ?

Leonelgayard on June 30, 2012 6:15 PM

There was this fella once, gay dude, bad habits but quite bright, Turing, or summat, had this idea about what could do what and what could do anything. It seems PHP = FORTRAN = COBOL == (Just to piss you off), PL/1(What a fucking horror that one was) = Python = Ruby = Algol = Algol 68(see how old I am) = OK, you get the point.

When I'm not hacking about my computer I work with tradesmen - plumbers, carpenters, electricians. You should look at their tool boxes. Horror, upon horror, chipped chisels, busted wrenches, dull saws, bent drill bits, und so weiter.

There is no perfect tool. Well, except maybe Obama.

Fred Z on June 30, 2012 8:31 PM

I think what everyone's missing here is that PHP is CHEAP CHEAP CHEAP! If I need to set up a web department I know I can get three or four PHP monkeys for the price of one .net guy, and in my labour market (Thailand) there just are no Ruby or Python guys around.

I'm not building the next google, just very simple sites and processes. These days I don't even need to cut code, just poop out brochure sites running WordPress.

Any replacement for PHP has to:
1) Be easy to learn. I should be at 'hello world' within 10 minutes or less.
2) Run on both Apache and IIS fairly easy and be simple to set up.

Dan on July 1, 2012 12:00 AM

I worked in PHP during college for my job at the University... it was fine but I didn't grow to like it. I'm a Microsoft stack guy but even Javascript is more fun to program in than PHP. I definitely prefer C#/Javascript and the barrier to entry for both is so low now what with all the freebie editors (Web Matrix, VS Express, etc).

Kamran Ayub on July 1, 2012 6:29 AM

It's definitely time you tried Lasso 9. Probably the most elegant language on the planet right now: http://www.lassosoft.com.

LassoFreak on July 1, 2012 7:03 AM

Ok, so PHP is not perfect, but I don't see you pointing out any good solution to use instead if that exists. If you don't want Rails, a big Java Enterprise or some Bill Gates server.. then what are you left with?

Hajo19673 on July 1, 2012 12:42 PM

I cannot speak to the solution to the alleged problem of PHP that you and many other programmers, when speaking at your highest levels of snootiness and condescension, have lambasted innumerable times, beyond the point of tedium, as you yourself point out in this post.

I am not a programmer, but a lowly scripter, an Applescripter at that, which is actually why I'm writing, because of the passing bashing it was given in one of your quotes.

Enough with the crapping on Applescript. It gets things done, it leverages the power of first-class applications, such as InDesign, TextWrangler and hundreds more in such a way that it enables non-programmers who don't care about clever list-sorting algorithms, to accomplish important tasks for real projects for real money, quickly, and without having to become 'real' programmers, which as you have made so clear, mere mortals should never try to do anyway.

Maybe PHP is popular because it works, because it is easy which is interesting, because it yields results without a lot of mucking about in hyperspace. Easy is interesting, hard is boring.

Personally, if all I was going to do all day was pull out nails, I'd take the double-claw hammer, thanks. I guess I want to take the easy way if the destination is the same.

Of course, if you and the other code critics were REAL programmers, you would have written your own replacements for PHP, to your exacting standards, using REAL languages that don't use wussy crap like memory management. Get down to the metal or get off the pot. Don't try to learn though, please.

Orcus_magnus on July 1, 2012 12:47 PM

The problem here is that Jeff and a number of others don't understand certain dynamics and how significant parts of the web really work. While language choice may have some meaning for mega web stuff (ala Google, FaceBook, Twitter, Digg, etc), there happen to be a fair number of people out there not doing things at that scale, and don't really give a shit about languages at all. They want something done, and they typically want it done as inexpensively as is reasonable. Those are the real driving factors for some significant chunks of the web, chunks that PHP owns.

For all the PHP bashers, here is my employer's typical scenario: large, well known local non-profit wants a "state of the art" site (of course by their definition, meaning it has to look "cool"), with an easy to use and flexible CMS, a blog, an event calendar, and they want to manage a large number of forms themselves. Some forms require payment processing. They don't care a twit about languages. This is very easy to do with WordPress + GravityForms ($99 developers license). No backend programming required, at all. Only frontend templating stuff. On our end, its a no brainer. There is nothing else out there, except maybe some other PHP stuff that could do this for anywhere near the same budget. I could write all this from scratch, or probably get some pieces of it with other frameworks, but then we move from low to mid 5 figures to well in to six figures. Why should we do that? Because PHP sucks? Get a life.

At the end of the day neither the client, nor the owner of our web shop, nor our staff gives a rat's ass about the language itself. Its totally irrelevant to our business, and many, many other businesses out there generating web content. We want what our clients want: the "best" (as determinded by the client) finished product we can get with the least expense. Thats it.

If somebody can come up with a Python|Perl|Ruby|WhatHaveYou ecosystem that is as extensible as those core PHP apps like WordPress (20,000+ plugins), Magento, Drupal, Joomla, etc, and you can produce a *better* end product, maybe you can start moving some of us in the trenches doing low end grunt work to your point of view. Else, you are just talking pie in the sky, wasting bandwidth and bolstering your own egos.

Halburgiss on July 1, 2012 2:25 PM

The real problem is PHP didnt evolve. Other languages learned to standardize (camel case or Underscores in functions... not both) and have started doing 'convention over configuration' like Rails (Ruby), Grails (Java), Django (Python). PHP is still a mess to code in.

And forget ORM because there is no good solution that compares with Hibernate yet... especially not for PHP. Personally, I just switched to Groovy/Grails because it has become AMAZINGLY mature, can be compiled/scripted, makes use of Spring/Spring security and other libraries, has a load of plugins and can integrate flawlessly with Java.

After doing LAMP dev for 13 years and personally working with Zend, I can tell you they have ZERO plans to improve the language and have told me as much.

Orubel on July 1, 2012 6:16 PM

Rather than bickering about the best/adequate language or framework, why don't we create something new, or at least improve something already good? We now have some hindsight on what makes a good language, particularly when it comes to the cloud. Many good things come out of dissatisfaction with the way things currently are.

Move forward people! If it turns out to be really good, people will come!

Williamkentler on July 1, 2012 8:05 PM

I'm a PHP programmer by trade. *Ducks* I loved this article, and in many ways you are right. If someone came up with a coherent alternative to PHP we would all be using it. But really, nothing comes close to it's ease of use. PHP has many faults, but the things that it does do well, it does the best.

I would be interested, what do you have in mind? What would make a good programming language for the web in your eyes? What would you do better then PHP? You have the ear of a lot of programming, you might be able to make this happen.

Mark Tomlin on July 1, 2012 9:57 PM

I've got a $2 bill that says Jeff's working on something with Python.

Ruby (Rails) is far too hipster (and far too convoluted for anything practical) for a long-time .NET developer to embrace. Philosophical differences aside, Rails is a lot less about solving problems and a lot more about the meta of solving problems.

Node.js -- maybe. Seems too experimental to me, though. It's the next great ooh-aah-look-at-that thing. It'll make your toast, it'll wash your car, it'll rub your shoulders after a long day! Oh, yeah, it'll kinda sorta let you write some code, too. But all the cool kids are doing it! All the cool kids that loved RoR 2 years ago.

Perl? Ok, I couldn't even finish typing all 4 letters without starting to snicker.

Python is lauded as a language that promotes good programming habits. Yes, you can write FORTRAN in any language, but Python actually goes out of its way to encourage you not to. It's lacking the ubiquity and the breadth of libraries and support of the bigger contenders, but I would say that's actually a good thing when you're looking to start fresh, rather than carrying along 18,000lbs of garbage for the ride and trying to pretend it's not making you really tired.

Cttcpmgo on July 2, 2012 12:46 AM

Heh, this reminded me of the good old post about Magpie Developers: http://www.codinghorror.com/blog/2008/01/the-magpie-developer.html

Especially David Megginson's process, which starts with " Elite (guru) developers notice too many riff-raff using their current programming language, and start looking for something that will distinguish them better from their mediocre colleagues."

And the first thing that comes to mind is that this whole JeffScript idea is yet another iteration of this process, but there's another thought which emerged from this statement.

No matter which language becomes The Next PHP, there will be a lot of riff-raff programming in it. In fact, that's what makes PHP so popular. It's so easy for mediocre and beginner programmers (and even non-programmers!) to write something in it, with little effort.

So, if you want to make the The Next PHP, it has to be even simpler for these people to get their shit done. Otherwise you end up with yet another footnote in history. And somehow it has to manage to stay mind-numbingly simple, while fixing all the pitfalls of PHP. And that's the hard part, IMHO.

Vilx- on July 2, 2012 1:03 AM

If you don't like PHP then don't use PHP hahaha!

Bryantan16 on July 2, 2012 1:59 AM

To me all of this babbling resembles the OS ideological war: windows vs linux. Some people just can't live without spitting on the mainstream because it is mainstream. Surely there are always pros and cons. Pointing them out and discussing is a good thing. I mean the real ones. The misfit hyperboles such as the double-clawed hammer annoy me. Clearly having nothing constructive to say one should STFU.

I agree with Jeff's "work to fix the broken or create an outstanding alternative". However, it's always easier to vent one's frustration then to create awesomeness. This is the sad truth I'm aware of.

Aoi Karasu on July 2, 2012 2:05 AM

If you don't like PHP then don't use open source software like Wordpress, Drupal, Zencart, PrestaShop and even Facebook :))

Bryantan16 on July 2, 2012 2:06 AM

PHP may not be the nicest language BUT it works easily and with almost every server without the endless configurations and server addons that others seem to use.
I tried ruby, perl and python and java etc, but to actually configure a server to run these is a nightmare for novices etc.
PHP just upload the files and call directly from html if necessary. Simple!
I tried for days trying to configure my server to run ruby on rails etc. What a nightmare. End of day. restore and stick with PHP and javascript!

Dazza J on July 2, 2012 2:45 AM

"..One of the explicit goals of my next project is to do whatever we can.."

I like the sound of that. :)

Robin Maben on July 2, 2012 4:00 AM

@Robin, @Jeff - As I said - what's the project, who are "we", and where can I join? :) That is, if it's possible, of course. Since it's opensource, I hope that the development will also be open-ended, and input/code from outsiders will be welcome.

Vilx- on July 2, 2012 4:13 AM

I agree with Jerelunruh. Laravel is pretty nice. You should check it out.

http://www.laravel.com

Hediedforme on July 2, 2012 9:45 AM

PHP is an amateur language, coded and maintained by amateurs. There's nothing particularly wrong with this as long as that's what you expect. If you expect to run any sort of mission-critical system with it, then caveat emptor.

How is it amateur? Mostly through very poor design. Here are some examples.

Having the same operators for comparison of strings and numbers just doesn't work in a weakly typed language. All of the coercion that goes on behind the scenes breaks stuff. It's how you get intransitive equality operators ("foo" == TRUE, "foo" == 0, but TRUE != 0). It's how you get long strings that happen to look like numbers (password hashes, perhaps?) being equal when they're not: "123456789123456789123456789" == "123456789123456789000000000"). It's how you get things like NULL < -1, yet NULL == 0, meaning that sorting is nondeterministic (big problem).

Other concepts are simply not understood properly by the designers. This is the only language where the ternary operator is left-associative. This code:

TRUE ? "a" : TRUE ? "b" : "c"

yields b in PHP and a in every other language in existence that has a ternary operator.

Maybe most egregious of all, this is a language that was created basically to write Web pages. At its heart, its job is to read plain text requests and write plain text responses. Yet after 17 years in service, the designers don't understand enough about the domain to introduce proper Unicode handling into the language.

If you can deal with stuff like that in your development language, then more power to you. I wish you the best. I personally am very wary about using such a tool no matter how good I am at wielding it.

Thomas on July 2, 2012 10:35 AM

@Daniel: I don't agree with your debugging criticism. If you're using "echo" to debug a complex project, you're doing it wrong. Use a server-side debugging setup, and you'll see its equally powerful to, say, Visual studio debugging.

On topic: I can't argue about PHP's poor language design, but I do want to put it in perspective. In two parts, a technology part and a business part.

Technology-wise, many (semi) professional PHP applications nowadays are built upon pretty good PHP frameworks, most based on the MVC pattern. It's a valuable pattern to learn, as it is used across languages and platforms. These frameworks do quite a nice job in somewhat enforcing seperation of concerns and within each layer, helpers and utilities are offered to help out at a detailed level. When applied correctly, you'll usually end up with a PHP application that is maintainable, which is a major improvement from the typical HTML/PHP spaghetti PHP was known for.

Looking at the kind of applications one builds with PHP, they're usually data-driven websites. Typically you will not find a lot of business logic or processing in these applications. As such, only some core aspects of PHP the language are "touched", such as string manipulation. While that exposure may be a nasty one, it is a manageable one. It only takes a few projects to know the ins and outs and to work productively with it, despite its shortcomings.

You may argue that getting used to a poor language is a wrong attitude to begin with, and that we should long for a better one. I agree. But this is where the business part comes in. Before I get to that, one more thing...you know what else sucks? HTML. And Javascript. And CSS somewhat. Browsers suck as well. Love it or hate it, but the web is a big hack, none of these technologies were ever designed to produce real applications. Still we do, and we will continue to do so.

Business-wise, nobody cares that PHP is a poor language. Nobody cares that something is "not enough OO" or doesnt have namespacing. What makes PHP a business success? Here's my view:

- It's a gettings things done platform
- It's widely available
- Staff is widely available on the market
- It's cheap
- It has a low learning curve (well, not really if you "proper" PHP)

It delivers. This doesn't mean other platforms don't, it just means PHP delivers and that makes the world go round. I think you will have a hard time building a relation between any of the supposed technical shortcomings of PHP, and actual negative business outcomes. And therefore, those shortcomings are not important enough for an alternative.

None of this changes the fact that PHP as a language sucks. I welcome its successor. You could opt for Ruby, Python, anything as a better language but I just want to say it needs to become as widely available as PHP. With that I don't mean hosting. There's more aspects to it. A very important one is the job market. You could become a kick-ass Ruby specialist but depending on your geographic location, the job market for that may be tiny or non-existant. We need something way better than PHP but it also needs to be as widely available in every aspect that matters.

Ferdy Christant on July 2, 2012 11:17 AM

Except now it's 2012, and fellow programmers are still writing long screeds bemoaning the awfulness of PHP!

I briefly flirted with using PHP for a personal web project around 199... 6? 7? Back when they still openly called it "Personal Home Page[whatever]".

It (PHP) was a barely-documented pile of random code then.

It's kind of terrifying that people are still using it... deliberately.

(Tati: That's not a Microsoft page; they just contracted registration for a conference out to some media company. Nobody has an obligation to dogfood such that they only use contractors who use their own tools.)

Sigivald on July 2, 2012 11:26 AM

PHP is popular, for the same reasons JS and Wordpress are popular.

They are:

1) Intuitive, easy to use (think apple products)
2) Popular and it's easy to get support.
3) Web hosts provide it for dirt cheap, ASP.NET+Windows hosting would be a lot costlier, plus a really deep learning curve for the framework. If the same noobie tried picking up C++ or Java, as if it were PHP, they'd be in a world of hurt.

PHP just works, it because popular not in regards to its flawed design decisions but how easy it solved problems. JS suffers many of the same problems. The different with PHP is that there are alternatives and yet, it still remains the king of server-side programming languages in general (because the other solutions are more complex).

C++, Java, C# were all carefully designed languages and enforce that you learn real programming concepts to get something up. They are also more commercialized solutions, which means they are not for the majority. The only way for something to overtake PHP (and be elegant), is for it to be as available, cheap, and intuitive.

I have deep knowledge of HTML and CSS and I'm learning different languages (MooTools, PHP, Python, will be picking up C++, SQL as well). I want to try my hand at solving problems in each and see what appeals to me when it comes to solving different types of problems.

Python is personally my favorite language in general, but I'll be developing web applications in PHP for some time. If you're disciplined and learn good coding habits, you can engineer great code. Just don't copy and sling, try to UNDERSTAND why you make decisions in your software.

Write bad code first, then write it less bad.

Coolelemental on July 2, 2012 3:09 PM

I think of PHP like those old beat-up trucks that you see on the road that look like they are going to fall apart at any moment. They have all kinds of tools, random bits of wood and the tailgate has been replaced by plywood.

Thing is, as scary looking as that contraption as, it is making money for the owner. *This* is why PHP continues to operate: you can make a website trundle along from job to job with it. Is it unsafe? Sure, but mostly for the people *behind* it, hoping those 2x4s stay put (who represent the people who keep hoping that PHP driven site doesn't leave their personal data scattered all over the information highway).

John Lopez on July 2, 2012 3:50 PM

@sadaek is right on the money. These are exiciting times for PHP. While the language itself is horrendous, take a look at the frameworks that run on top of it. Symfony, Composer,... Albeit, with their flaws are excellent tools which keep developers from reïnventing the wheel as far as the low level stuff (session storage, file handling, request routing,...) is concerned. Writing your own mini CMS/F might be exciting, but today, don't even think about pushing them beyond your own personal projects. It's just plain redundant to do that.

It's also all about the sort of tool you need to get the job done. Wordpress is a blogging tool with a history. It's internals are a pile of steaming excrement, I agree. Yet, the front end is great for users and with a few clicks, you can easily set up a blog. But don't start to build entire platforms on top of it. It's just not meant to do that.

I do agree that the low level functions of PHP are a mindfart. Having said that, you can still map your findings here: https://bugs.php.net/ Mind you though, PHP's biggest issue is its' legacy. Powering the Web comes at a cost: you can't just start rummaging around at the low level without breaking all those hacks people have written over the years. It's probably just cheaper to leave those in. If Python had the same success, we'd probably be taking a dump on typical Pythonesque monstrosities that we don't even care about the slightest bit today.

Netsensei on July 3, 2012 5:43 AM

I'm a fan of PHP - and I've been using it for a while now. I prefer to work on top of Code Igniter (a nice MVC framework).

I'm also a business, I provide services to my clients, blazingly fast, solid and DONE when they're supposed to be done.

If you *really* want to replace PHP with a language you think is "real", well, it will be challenging. As a businessman, here is what it must be able to do:

1. Be anywhere I want without install/setup complications. I should NEVER have to worry about it being everywhere and ready when I want it. I don't want to waste time or my money setting up some software just so we can start to actually work. I don't want a dedicated person to the setup and configuration of the development language, its tools or plug ins or requirements and so on. That is just a waste of a job on something that adds no value at all.

2. It must come with adequate tools to complete common tasks - session management, database connectivity, file management (upload, file system access), image manipulation, compression, security, email, and so on. These should all work "out of the box" without much configuration or concern about the server or what not. Having to develop these is a waste of time and money.
2a. To use said services, I shouldn't need more than a couple lines of code - or even a single line of code to implement it.

3. It must be extremely well documented in plain language (English and all) - with implementation examples that are meaningful. Seriously, the autodoc "documentation" is utterly useless. I can usually find the solution to any issue I have with PHP using Google in a matter of a few searches. And when I say 'solution', I don't mean a document page that explains the function I'm wrestling with, I mean an actual example of the code that solves my problem almost line for line exact. Otherwise, I've got to spend time developing solutions to known problems - there is nothing new under the sun and, pretty much, no matter what the task is, someone somewhere else did it before you.
3a. It must also have a serious amount of third party detailed examples of implementation.

4. I shouldn't need any special tools or special/additional skills to use the language. By this I mean, I shouldn't have to waste time learning (developing a skill) how to use the server merely to complete using the language for any reason. If the language requires compiling, it should happen automatically without me having to tie files in or deal with configuration issues merely to see the code work. In PHP, it is upload the file, open a browser, test it, done. I shouldn't have to do more to work with any replacement. I shouldn't need a special IDE which can work with the language to make it so that I can do what I do in PHP (instant testing). The additional time to merely compile and configure files for compilation adds no value to the project and is an inferior aspect of a language.
4a. It should be loosely typed. I really don't care if the data is an int, double, float, char or blob, just deal with it as I want you to. Seriously, casting variables or creating functions to convert them is "better" than the language automatically doing it? The best smartphone has one button on it and the touchscreen reacts differently depending on how it is interacted with, I don't need to tell it when I'm scrolling to scroll, or when I'm tapping a link or resizing the page, it just does it automatically - this is the best design out there - and I think there is nothing wrong with expecting my language to be just as flexible, especially when it really only matters to esoteric metrics on what is a "real" language or not...

5. It needs to work flawlessly with mySQL and/or any other database that shares the same distribution as mySQL. It should be able to manage the connection and all transaction to the database and it should do it in a few lines. Creating our own connection code or transactional libraries is a waste of time. They should be extendable for custom functionality as needed.

6. It needs to come with complete MVC frameworks, from small, light and tight to large, complex and complete. It needs to have a TON of applications built in it so that I can take one off of the shelf and modify it and then publish the work in weeks or a month. I shouldn't have to reinvent the wheel ever.

Essentially, everything above is related to rapid development to contain development costs. My clients don't pay for esoteric development done at whatever you think is "right" - they want something setup, installed, stable and working NOW. Until you can provide a language that is as versatile and economical to develop in, PHP is simply a better language because it can do that while all of the other languages can't. The measurement isn't how well the language adheres to some metric or design concepts that you believe are relevant, the measurement is how the language solves the problem.

Right now, I have a client who uses PHP and mySQL to serve over 2 million visitors a month, I've seen the complexity of the operations and to re-do this in one of your so-called "better" languages would take a considerable budget and a team of several developers (having seen similar projects at a corporation I'd worked at a few years back). I'll complete the MVC re-write of the site in a few months on my own (have about three weeks to go to complete phase 1, phase 2 will take another two months - then its done - and I'm part time with them). The best language is the language that gets the job done for the most economical price. Simply paying more to develop in a "better" language that adds no value to the end product isn't a better, but a bad business decision.

Paul Davis on July 3, 2012 9:23 AM

It seems to me that PHP took off because someone who doesn't know how to code can start with index.html, rename it "index.php", add a variable here and a tweak there, and before you know it you've got Wikipedia. And nobody wants to rewrite that from scratch in a new language.

You could do the same thing (roughly) with Python, with a few modifications. You'd need a ".pyml" (or whatever) format for embedding Python in HTML-- but then you'd need to convince all the web hosts to include it. (Which might not be that hard, if there's enough demand: they nearly all support Python.)

The thing that's hardest to replicate is the ecosystem around the language: starter guides and how-tos that assume little or no programming knowledge. But perhaps a StackExchange site could help with that.

As a replacement for PHP, Python seems to be the best language: it was designed for beginners (kids, actually) while still being reasonable for use by real software engineers. I'm not a big Python fan, but having used both, I'd take it over PHP in a heartbeat.

The other language worth considering is JavaScript. Being able to use the same language client-side and server-side makes a lot of sense in terms of reducing the learning curve.

It seems a little odd that Jeff would take on the project of killing PHP when he doesn't want non-programmers to program ( http://www.codinghorror.com/blog/2012/05/please-dont-learn-to-code.html ). I can't imagine him succeeding with a negative attitude toward his core audience. Still, I can't complain if all we get is a halfway decent PHP alternative that gets used by a few high-profile open source projects.

Dleppik.wordpress.com on July 3, 2012 10:44 AM

PHP for all its brokenness is easy and it's small in workflow terms (code then hit refresh to test), and I don't mind using it to do websites, but god damn that dollar sign convention is so annoying. Makes typing variables a pain in the ass.

Nick Bedford on July 3, 2012 6:37 PM

With a good framework and sensible abstractions, and using an IDE takes away most of the frustration you guys mention. I feel like most of these arguments are, "I saw bad code and don't want to develop solutions so it's time to argue that the language is horrible." I mostly agree with ChronoFish And More's simple assertion, the language is extremely fast to develop with and if you have any sort of CS training and discipline with normal coding standards, PHP apps can end up having very elegant and sensible solutions for projects.

Getting confused from explode() when you have an IDE popup to show you which variable goes where is extremely nitpicky in my opinion. If it really gets to you, you can always find an object oriented library of the languages constructs so that you can do a less confusing $array.explode('/') or something similar.

I agree that there are a lot of things that should simply be deprecated as the language moves forward, as sometimes having 10 different ways to solve a problem results in baddies coming in and making hard to work with apps.. but at times like that I feel it's times like that to show that there are more efficient and cleaner ways to do things and build up the programming community :P.

Antoine Sledge on July 4, 2012 9:34 AM

Coming from a programmer that started off on Visual Basic then moved to PHP/Javascript and is in the process of Transitioning to Java

What I like about PHP is the Inline User Interface, automatic garbage collection and memory allocation and what I hate about PHP is the Inline User Interface and the lack of Thread control

From my webwork PHP isn't meant to be a large scale, its suppose to be quick and simple. And from Experience you can make it as such.

However, what i don't like about php is the lack of Seperation from User interface from the Core. HTML and CSS are established User interface tools. Web Designers Learn this. However, as a programmer, Iam forced into a position to treat it as part of the framework costs which I desipise.

Likewise, when it comes to threading, PHP can be difficult to work. Since I'm forced to use multiple documents for different people calling one document and setting sleep variables to make sure they aren't reading it too often. Was a bit painstacking, though also an interesting puzzle

But I'm less inclined to say its a worhtless language than to say it needs a proper library. Wordpress was an attempt that5 I think failed horribly. Magento is worse for the simple fact Layout.xml is their attempt to make a new HTML. I do think that PHP is fine for the fact its quick and simple, though obviously it can use some changes.

Sam Tobia on July 4, 2012 9:39 PM

Isn't it ironic that one of the better stackoverflow clones is written in PHP :-)

Robert Barnesi on July 5, 2012 12:55 AM

PHP definitely sucks if you use any real programming languages. It has always sucked, but I just think of it as server side duct tape.

Ericfickes on July 5, 2012 9:00 AM

This was a very funny article and I just loved it!

I remember very well my first contact with PHP when I said: "C'mon you can't be serious..." after reading a few lines of code and tried to understand the language.

And that general view that "it works, so I f... don't care" it is a worldwide tendency on disregard critics and take shortcuts. And I feel that goes beyond code... unfortunately.

Pretty soon we will have PHP like MDs ("Take that medicine... it works and solve your problem right here and right now... ");

Sawamu on July 5, 2012 9:49 AM

Is there something in Python like Wordpress? just drop it in your webserver, pull up a installer page with 2 or 3 questions and it's ready to use.

At least with stuff like Symfony2, PHP seems to be getting better.

Anon1Y7Y7eju on July 5, 2012 5:11 PM

Excellent article, thanks for the same. The very aspect PHP is so pervasive is the fact that it is easy to use and is being used both by the coding and non-coding community. Until a better alternative is available, PHP, for all it's faults, is here to stay.


Subodha72 on July 5, 2012 5:29 PM

The only way I see that PHP could be displaced is if you take PHP and fix its faults... and then make it so, that the new JeffPHP can run oldstyle PHP and newstyle PHP side-by-side in the same file. This would offer both an easy migration path for existing code and an easier learning curve for old-time PHP coders.

Vilx- on July 6, 2012 12:30 AM

I does matter that PHP sucks. It matters a lot. PHP can only be safely used by a top shelf, well-trained programmer with a ton of patience. Except that a well-trained programmer would never use it because there are countless better options. So that leaves the dregs to use PHP which is also not shocking, because the PHP dev team is filled with amateurs.

This means that PHP is really useful to no one and should be used by no one.

I am not surprised that you don't understand this since you are obviously under-educated. Time and time again, you have shown this. Have you figured out that all programming is mathematics yet? I would be impressed if you have finally learned what math is, but I know you haven't.

PHP sucks, if you use it you have no business programming. Full stop.

Vilanye on July 7, 2012 1:40 PM

"A low barrier of entry is not a bad thing."


It is a very bad thing. Programming is the only profession that allows untrained people to work in the field and we all have been paying for that.

Programming is a professional endeavor, if you do not have the brains or the will to get an appropriate degree(CS, CSE, etc) than GTFO. Without formal training, programming is black magic.

Look at Jeff Atwood, he is untrained and read some of his stuff, he simply lacks the understanding of computers,computing and mathematics to talk intelligently. Instead he takes his third-graders understanding of math and tries to apply that to debunk Dijkstra. To Jeff, programming is magic, just like it is to 99% of the people who use PHP.

The internet is an extremely unsafe place because of these amateurs with no clue what it going on. PHP 'devs' lead the pack in producing unsafe applications.

Vilanye on July 7, 2012 2:40 PM

"Ok, so PHP is not perfect, but I don't see you pointing out any good solution to use instead if that exists. If you don't want Rails, a big Java Enterprise or some Bill Gates server.. then what are you left with? "

The problem is that PHP is not perfect, nothing is.

The problem is there is nothing good in PHP.

Pointing to crappy $5 hosting means you don't have a problem worth working on. It also means that Heroku is going to be much cheaper for you, and it scales effortlessly if you need it to. It is also simple to deploy to.

Rails is fine and is a snap to deploy. Absolutely simple, of course you need the CLI, but PHP needs it as well. The crappy hosts just do it for you and you better pray that they compiled it in a way that whatever you want to run on it will.

The rest of your comment it typical of ignorant PHP "devs"(is there any other kind?) Other options include:

C - you would be nuts to use this
C++ - you would be nuts to use this
Perl
OCaml
Scala
Lisps - CL, Clojure, etc, etc, etc
Erlang
Javascript - node.js or even on the JVM
Smalltalk
Haskell
Python
Ruby - Ruby is not Rails, and the Ruby ecosystem is much larger including other frameworks and template libraries and other libs. Most of the web-centric Ruby libs are Rack compliant so they all work together seamlessly. Yes, you can mix template libraries in a single web app and even frameworks like Rails+Sinatra.
JRuby - Gives you the best of Ruby and Java and is up to date(ie runs on Java 7 and is more or less Ruby 1.9.x compliant(Some Ruby features just won't ever work on the JVM, but it is not a huge problem since those few features are rarely needed) so it makes sense to put this separately. Unlike say Jython, which is quite poor and lagging significantly behind Python.
This list could go on and on.

With the exception of C and C++(correct me if I am wrong) all of these have frameworks if you need them and they all have the needed libraries if you don't want to use a framework

Of course your typical PHP "dev" isn't educated enough to easy change languages, which is why a competent CS program doesn't teach languages, it teaches concepts.

Vilanye on July 7, 2012 6:51 PM

Please stop writing novels on how BAD php is - without any code in them. It's useless waste of internet space and user time (stuff tending to be infinite is not a good enough excuse to waste it!).

Please, present your arguments with code, and show samples of how things can be better with the language you happen to think is "Da Best Ting Eva". Too much of it to post in a blog? No problem, just make+link a Git repo for it, we'll go ahead and check it out.

I wouldn't expect anything less from you, Mr. Atwood.

Adityamenon90 on July 8, 2012 10:15 PM

I agree with Hardikdangar, PHP is fine as a simple frontend language. These days I mostly build web applications so most of the code is JavaScript, I use PHP for templates, routing and to handle building JavaScript and CSS and including it in the page, this is the simple stuff PHP makes very easy. For more complex server side functionality use something else and have PHP or JavaScript interface with it. Our core application is actually written in C.

David Buttar on July 9, 2012 8:31 AM

The problem I've had with PHP ever since it was started is not that it's a bad language, but that it started out as a bad language in exactly the same way that Perl 4 was a bad language (unsurprisingly, as PHP developed from a Perl script) and then proceeded to fix those problems, one by one, in exactly the same way Perl had already done it, several years before - and yet PHP became very popular while most people trying to use Perl for web programming are still asking basic questions about CGI scripts written in Perl 4 like it's 1994.

One of the best proofs of Worse Is Better that I ever saw.

reinierpost on July 9, 2012 9:41 AM

Interesting article. I'm a PHP Developer and I certainly understand some of the issues with PHP and feel no need to try to defend it.

I've had to inherit PHP code that makes me want to pull my hair out and scream - the spectrum of code quality is tremendous. When someone says "I can code PHP" that literally means nothing.

Personally, I'm a big CakePHP user and I can't settle for anything less. Admittedly, I couldn't understand CakePHP until I learned MVC through Objective-C and iOS Development. This probably means I'm ready to move into something else more serious for my server side implementations. PHP has certainly not been enough to make me the best I can be.

That said, I'm really against this blind and aggravated PHP bashing. To the character "Vilanye" above - IMO you are the worst kind of coder/developer not because of your code quality but your attitude toward other developers. That kind of tone just alienates peers and does no good to this industry. Calling PHP developer names doesn't make this problem better, it just makes you look like an ass.

I'm always wiling to personally improve, but when people bring knives to the party, I leave.

Kyle Newsome on July 9, 2012 11:19 AM

@Vilanye

The rest of your comment it typical of ignorant PHP "devs"(is there any other kind?)

Seriously? It doesn't matter what language you programme in, you're still a complete and utter arsehole.

Psychoticmeow on July 10, 2012 3:00 AM

Nice about the PHP articles, it is really informative.
http://emailmarketing.comm100.com/email-marketing-ebook/email-unsubscribe.aspx

Chip San on July 10, 2012 7:00 AM

His analogy is amusing, but I think a more apt analogy would be that PHP is a hammer and phillips screwdriver when most web developers have become accustomed to nailguns and square drive drills. After all, an experienced carpenter can use a normal hammer just fine, but it will take him a bit longer, while a novice is likely going to hit his finger a few times and make a few holes before he gets it right. I almost have to wonder if the person who wrote the original entry was just recently introduced to PHP. Aside from a few bugs introduced in 5.4 nothing in there is news. None of it was news 4 or even 8 years ago. We get it.

Just as it's easy now to talk about how awful and inconsistent IE6 is, it's easy to trash talk PHP, because it's barely changed in 10 years. It's much harder to remember how much more horrible everything else was at the time it rose to prominence. Remember what else was out there in 2004? ASP had all the quirks of PHP, with a worse language, and a server stack that makes PHP look like a model of security. Java Servlets were slow, and had to be recompiled for every change, which was even slower. Ruby on Rails didn't even exist yet. ASP.NET was around but it was years away from a serious web development platform. The fact that it is taking this long to depose PHP when it stagnated so many years ago is an impressive testament to how far behind any of the alternatives were.

PHP was also the fastest option around for quite some time. (Or at least, the fastest in widespread use.) It wasn't until relatively recently that some of the other platforms were able to catch up to it performance wise even without cached compilation. If you have a caching layer like EAccelerator in place I don't think there's still anything that can touch it. (Could be wrong here - it's been a while since I've done close tests. These days I avoid PHP whenever possible.) To me, the linked blog's arguments for having app servers separate from web servers seems to boil down to "My web servers can handle a couple thousand requests per second, but my web app framework can only handle a couple dozen." To me this is more a criticism of the other web development platforms out there, and another example of why PHP is still around. Obviously most people don't need that level of performance, but for those who do, it certainly makes a big difference.

Andrew on July 11, 2012 2:28 PM

All that said, I love the hammer, and I badly want one to hang on my desk...

Andrew on July 11, 2012 2:30 PM

%s/PHP/VB/g

Leej on July 12, 2012 2:07 AM

PHP seemed cool back when I didn't know how to make websites. It gave me this false sense of confidence that making websites was simple. Then I grew up.

I'd love to use the alternatives but I think Ruby sucks too, I like it when data type rules are enforced at compile time instead of runtime. No matter how you design a website you will have to enforce data type rules somewhere, why not knock it out before the code even runs?

I'd wish Perl was an alternative, but honestly I think it sucks more. It's a better procedural language but that OOP soup is a nightmare. No thank you.

I'd wish C# was an option, but I don't want to pay MS that much money. I don't see the value in locking myself in to their technology. No thank you.

I'd wish C++ was an option. I absolutely love C++, unfortunately it can also be incredibly tedious at times. I would use C++ if there was a modern and well established web library for it, but I'm afraid I'll be stuck on my own trying reinvent wheels because of missing documentation. Furthermore, there goes any chance of collaboration. Most programmers aren't sharp enough for C++.

This is why I use Java. I am not a fan of Java and I think it's libraries suck, and it's implementation of generics without static typing support is backwards, but it's modern. Unfortunately, compared to PHP the setup is much much more complex and your hosting options are severely limited.

People use PHP because it's easy and it gives you the illusion that works just long enough for you to buy it.

Bernard on July 12, 2012 11:06 AM

I *like* PHP. It has its quirks, but I've not yet used a language that didn't. The C-like syntax is comfortable and easy to grasp, and I spend less time thinking about my environment and more time working on solutions.

The double-clawed hammer analogy only works when there are regular hammers available. I would contend there are not. There's hammers without claws, hammers without handles, hammers with axe heads instead of flat heads. Once you reach a certain level of understanding in ANY language, you will have encountered enough quirks and oddities that you'll hate the damn thing.

I think this is perfectly natural; it doesn't only happen with programming languages. Ever heard the phrase "familiarity breeds contempt"?

Chris Baker Gr on July 13, 2012 1:09 PM

If this was my first time reading a complaint post about a language, I'd be tempted to say "Yeah, it sucks! It's all PHP's fault!"

I'm more that the first to admit that PHP has its failings. I've even held PHP up for ridicule in my webcomic.

But over the years, I've realized: It doesn't matter! There has never been, nor will there ever be, a language so perfect that none can criticize it. PHP is a cynical language that says, "You're going to bitch no matter what we do, so who cares? Do you want to build something or do you want to sit around arguing about design for the rest of your life?" Because trust me, if we never designed a language until we had the perfect, crystal-clear consensus about The Perfect Design, we'd still be waiting for our first language.

The most successful languages, like the most successful governments and corporations, seem to fly by the seat of their pants not giving a crap about how to do it right. That says something about us. It says "We need to do something right now, whether it's right or wrong."

We'll still be having these debates centuries from now. But me, I just build. Starting from rocks and sticks, if necessary.

Penguin_Pete on July 15, 2012 7:57 AM

(1) You've obviously never tried to program Sharepoint
(2) what about using Mono and Apache ?

Ben McIntyre on July 16, 2012 6:36 AM

The art of writing good PHP is realizing that it is not, in fact, only a two-clawed hammer, it is a toolbox that puts the two-clawed hammer out on top and buries the normal tools way down deep where you only find them by looking for them. And then excludes several tools that everyone will eventually want to use. So what you do is you ignore all the weird, nasty, and funky stuff and focus on what works well and makes sense. And then you begrudgingly pull out the two-clawed hammer when you have to, because the only other hammer is ball-peen and damnit, you need a claw.

Regarding alternatives, there's a ton of them and some are gaining traction. I'm partial to nodejs for reasons I won't go into here (there's plenty to argue about re: javascript since using it wrong has been the default way of operation for over a decade now).

Justen Robertson on July 16, 2012 10:02 AM

Props for Flask/Django.

I've worked with teaching Python as a replacement for PHP to our interns, and the Pip vs Pecl comparison really wins folks over. I'm of the opinion that package management is actually MORE tedious with PHP.

Mark Asperia on July 16, 2012 1:21 PM

We can use Tomcat and build shared containers with dynamic Groovy/Java 8 code and work on the footprint.
It's a longshot but It would just work a thousand times better than php.

Guillaume Balaine on July 17, 2012 4:08 AM

So mighty websites like "Facebook" "Wikipedia" and "Wordpress" have their roofs upside down ! Then which website is properly constructed ?! This is called Bitching about something which you cannot stand!

Bhuvan Rikka on July 19, 2012 4:51 AM

After years of doing professional work with PHP I decided to abandon the language from my tool set, and it was a good decision.

Having a widely available alternative sounds too good to be true, considering that many many web hosts don't give you a real choice, even if they claim to offer Ruby, Perl or Python, and they are very slow adopting new technologies.

Good luck in making an awesome alternative, unless it's based on the imho even more abominable Microsoft stack.

One word about Rasmus, he may be "breaking the Web", but I don't get why people, who dislike PHP, feel the need to insult him.

While I agree on most of the PHP criticism and consider tools like Wordpress awful from a developer perspective, I think they are important as they've provided non-tech people a way of publishing on the Web for quite some tome now.

The Web would be just irrelevant, if only software developers were able to do so.

Yaph on July 20, 2012 3:51 AM

I have never been the biggest fan of php. My favourite language of choice is ocaml, with python and ruby not far behind. But I make my living writing web applications and not having the option to choose which servers those apps will run on usually means that php is the obvious choice. One thing I would like to point out, though, is that with version 5.3 and more recently 5.4, PHP now has a feature set that make it a worthy language to program in. If it had annotations (hint) then I would find it hard to find anything wrong with at all in practical application building. Add the fact that it has a decent market share of good web frameworks, including enterprise, micro and all between, excellent templating engines and suddenly the difficulty in finding fault with the venerable old workhorse increases rapidly.

Binaryten on July 26, 2012 1:29 PM

Ahem, may I reference, Windows command line hacks (http://www.codinghorror.com/blog/2005/07/stupid-command-prompt-tricks.html) and you're bitching about PHP?

C'mon. Give it a break. I agree PHP is a pain to work with, but it's no more difficult to work with than Perl.

Zippy Zeppoli on July 26, 2012 2:00 PM

There are only two kinds of languages: the ones people complain about and the ones nobody uses..

Eirfan on July 28, 2012 7:33 AM

"There has never been, nor will there ever be, a language so perfect that none can criticize it. "

This is true but you miss an important point.

The delta between the flaws in PHP and any reasonable language is not insignificant.

In other words, just because all languages have warts doesn't mean that they are all equally flawed.

That is something PHP "devs" fail to understand.

Vilanye on August 5, 2012 11:48 AM

"Seriously? It doesn't matter what language you programme in, you're still a complete and utter arsehole."

I know, the truth hurts. You can have my shoulder to cry on if you need it.

If your field of view is PHP or Java, you need to evaluate if you have any clue. Of course, if you had a clue, your field of vision would be much larger.

Self-trained language end-users have no business programming. PHP is written by amateurs for amateurs, therefore if you use PHP you have no business programming.

It is people like you and all the PHP defenders that cause me to support strict professional standards and licensing for all programmers.

Where I live a hair cutter needs to prove proficiency and get a license, but any old idiot(and lots of idiots flock to idiotic languages like PHP) can attempt to write software and infect the world with it. Makes no sense.

Programming is a professional endeavor. Full stop.

Vilanye on August 5, 2012 11:55 AM

"There are only two kinds of languages: the ones people complain about and the ones nobody uses.."

Said by a person that can not accept any criticism of C++ and the quote is self-serving.

Using it to defend something is the height of idiocy.

Bjarne, while being infinitely more intelligent and educated than any PHP "dev" is still using the fallacy that all items in set Language have flaws, then all said languages are equally flawed. There are many subsets of Language that are superior in significant ways over PHP and C++, though C++ also belongs to the superior to PHP subset.

PHP is better than Malbolge, Brainfuck, and Whitespace and that is about it. It is significantly, and irreparably worse then any other language, mainstream or not.

Vilanye on August 5, 2012 12:00 PM

What could I do after building Stack Overflow. Stop the evil reign of PHP? Seems legit..!! Hehe

mithunsatheesh on August 9, 2012 2:33 AM

"I can’t even say what’s wrong with PHP" without using metaphors. I love the double clawhammer, but metaphors alone don't make a point.

Lucian Hontau on August 9, 2012 9:23 AM

I am a 9 years PHP coder (not just LAMP) and also 2 years Node.js coder. I love both stack of technologies. What I think that makes the PHP great is not the language itself, but the community behind it. I found the community tends to be very open and constantly roll out great libraries. I remember back in the days when Ruby on Rails just hit the street, people all want to do "everything written in Rails and MVC" type of thing. But very soon PHP comes up with many MVC type of frameworks. Now, I found history repeats itself. Everyone seems to do "everything written in Node.js and Async fashion" type of thing. But again PHP comes up with an array of libraries that obviously inspired by Node.js. And I am one of the member in the PHP community to be in this process today.

Check out all the following great things in PHP
1. Composer: http://getcomposer.org/ Node style package management
2. DNode protocol for PHP https://github.com/bergie/dnode-php
3. PHP-UV, a PHP extension to talk to libuv, the core library behind Node.js
4. Pupcake, an early effort to make PHP perform Node.js type of functionalities https://github.com/superjimpupcake/Pupcake
5. React, Event-driven, non-blocking I/O with PHP
...

It is all about community. If the community can continue with the momentum and willingness to listen to the cool stuffs happening outside of PHP and keep improving itself, PHP will continue growing and survive, otherwise, it will go nowhere.

Jim Javathunderbird on August 18, 2012 7:36 AM

Have your say on this too..

http://fabien.potencier.org/article/64/php-is-much-better-than-you-think

Gaurav Sharma on August 22, 2012 12:36 AM

Only one language makes my eyes bleed more than PHP... Objective-C. I'll take a spoonful of PHP over ObjC any day.

Both taste really bad to me.

Michael Palmer on August 24, 2012 7:24 PM

The problem isn't PHP, per se, it's people who fall into the trap of seeing how simple it is to create "working" PHP applications, and then think that all this talk about quality and craftsmanship and design patterns is a load of crap.

The same could be said of the damage that old VB6 (and it's cousins VBA and VBScript) did to the software development profession - it created an entire subculture of what I call "Pinocchio Developers", that is developers who think they are real developers but just appear to be developers. When these people get into companies, they tend to foster a culture built around quick fixes and shoddy design, because it's all they know, and tools such as PHP help to foster this with how deceptively easy it is to become a "PHP programmer" without any knowledge of quality, simply by copying and pasting code snippets or writing spaghetti code. Then you get a developer in this company who DOES know about good design, and they become lepers since for years the company has operated on the notion that good design, craftsmanship (e.g. the SOLID principles), and all of these good things aren't really needed because Bob the Programmer built a ball of mud system using PHP, and it works just well enough that it doesn't crash and burn (as someone else said: Broken gets fixed, shoddy lasts forever).

That's why PHP sucks, and that's why PHP is dangerous: It isn't because it's a poor tool, it's because it blurs or even removes completely the line between a good developer and a bad developer.

Wayne Molina on September 10, 2012 6:32 AM

watch movies online is very easy and you do not need to have special knowledge for this. Besides, this way of watching movies is very advantageous. It helps save money on cinemas and DVDs, which can be quite expensive. You can create your own collection of movies and watch your favorite movie whenever you want.

Watch2x on September 12, 2012 5:45 PM

are f***ing fraudster they never deliver what u want and they always have some stupid rules to protect them; they are all fraudster do not deal with them anyone who doesn't want to get ripped off stay away from www. they miss deadlines and provide u something completley irrelavant to the subject u have selcted for research they provide links to references that do not exsist and give statistics on the wrong business areas; all who think that http://www. are fraudsters should join me for a fight against them and take them down i will post to anyone all the interaction notes and documents they sent me which even a 5 year old could writer better; they are all fraudsters and trick u into accepting the final version but when u review it carefully u find it doesn't make sense. they do not mind revising cause they will keep on sending the same crap over and over agian until the deadline passes and then they will refuse to refund u and offer you a stupid15% discount (hahah no one is that stupid). Please i warn everone out there stay away from its better u score a low grade than deal with these fraudster that u will pay ur hard earned cash and u will still fail and get caught for plagarism. Do not deal with the biggest fraudsters online "" please pass this message around they are the worst to deal will and will never deliver; i am only sharing my experience and for 6 months they failed to deliver what i asked for no matter how many times i wrote it down in simple ABC english; if you care about your work and want to get a good grade stay away from these communist F**kers; i will share information with whoever wishes to see what sort of nonsense low quality work being offered by the mobs.

Creeon on September 19, 2012 6:34 AM

I was introduced to this by a good friend as he though I was sinking with exam preparation. He recomened the company above that they would do some good work for me while >I concentrated to the more specialised parts. I contacted tham and asked whether the could fulfill the requests I had. One of those to have text book where extensions of the questions were. In just seconds they wrote back giving me assurance that they have all it take to do the work. I now asked them how payements to be conduct which they quickly helped me with. I paid and up loaded the work to be done. I really was impressed by the way things moved fast in here. A few seconds after payment was done, I recieved a message that a write had been assigned my work, this was nothing but good news again. Five minutes later one person from customer support asked me to upload the extensions of the questions. Now this is the very guy who assured me that they would have the text book. He had a name Rob. I wrote back to him telling him what he had promised me and this time I copied and pasted his own mail. He apologised and said they would get the book. Now there was total silence around. I wrote to the writer to find out if he was doing something. He never replied, well I thought he now was so busy. 8 hours before dead line he write asking for an extension. Support writes too asking for the same but none is giving a reason why an extension is needed. When I asked why, I got one of those classic answers, well I could not get the book from any library. Now comparing my home country, I wondered how USA could be this poor to fail to have this book in one of those Libraries. Well I gave in 24hrs. 30 minutes before deadlines the writer send a message expressing how sorry he was for failure to get finished, but promised to send part of the work to me. Before I even responded the work was up and the support service had named this "completed" I wrote to them asking what the meaning of the word completed was in this case, they excused with some silly excuse again. They now ask me to look into it and either approave or ask for a revision. when I looked at the work, I got a shock of how low the the standard was. Beside the fact that I had paid for over twenty pages didnt matter, I only recieved nine pages and nothing but low grade work. I asked these people to refund my money but asked if I had 24 hrs more then they would assign a new writer. I now had one day and half to hand in this work, well I said if this 24 hours is enough then I will use the remaining half day to prepare and hand in. I wrote in and asked this to be the last chance. I got Robs word and he even gave me the number of the new writer. 8 hrs later the writer asks for more information but this was solved again with that good for nothing support man "Rob". I scanned a few pages and send them in. There was no responce on this. Two hrs to dead line, Support(Zoey) writes accusing me for being late with the deliveries and that this meant a new extension. I now told him that this was enough. He said I had options, either to extend or to ask for a refund. I decided to go for a refund. He directed me on how to do it. On trying to access that place on the site, they had now removed the refund button. I wrote again but no reply came from him. Now some new girl answer directing me in the same place. The button wasnt there. Now I was getting, as it was time to hand in but I was busy fighting for my money and planning re-exam. After an hour I get a message that my work had been upload when I looked at the work it was the first piece of crap and no change same nuber of words,, just same everything. I rejected it and wrote back. Now they send a new piece of the same work with a button refund. When I pressed it, I got two options reject the work and ask for for money without work or reject the work, ask for money and take the work. I chose the first because it was very minor standard which I could not even hand or two it was also beyond dead line.
As soon as I pressed refund an automatic message came in that according to their policy I had to make the same piece of work and hand in to them in seven day or else I dont get arefund. When I asked why this was to make sure I didnt use their writers work. I found thie silly coz I imagined a company that had fail to meet a deadline fourt imes now was bust setting deadlines up for me. When I wrote to them asking about this some girl Bella said she would comment on that before the manager get into the case . Remember time was running for the work I had to hand in to them

Creeon on September 19, 2012 6:35 AM

Thank you

Minecraft

Wilecity on September 27, 2012 6:46 AM

I glanced over this article of, "oh no don't use PHP it's evil" generalizations. I'm not seeing exactly what the author is upset about? Security PHP issues? or what? In fact I just did a search on "security" on this page and walla, zilch, nothing that the author talks about.

PHP4, yeah maybe this author is onto something.

PHP5 with OOP - hell no, PHP5 with OOP ROCKS!!! Jeff Atwood, the author of this article is way off into a galaxy far far away in god knows where.

Use XAMPP or WAMP to develop on your computer. Don't put your code out there on the net until you know how to do security. Read up on Larry Ullman's PHP books and/or go to Amazon and read reviews on PHP books specifically PHP OOP.

Learn and use OOP (Object Oriented Programming) while simultaneously learn and use a PHP framework like Yii PHP Framework or Zend.

I LOVE using PHP, MySQL, and the Yii PHP Framework. LOVE IT!! Yeah, super, duper really LOVE it!

Peace out

Jescor on September 28, 2012 11:49 PM

Its not about hate, evil or php people being wrong. Its about choice and preference.

There nearly is a choice, an obvious one. Its just a bit to hard to deploy.

I've used PHP for years, made plenty of nice websites for happy clients. I'd like to have a choice in the language I choose for all my projects.

http://hashtwo.com/blog/the-php-singularity-1

ASecondWill on October 4, 2012 4:45 PM

"I'm trying like hell to do my part to make it happen."

Pardon my ignorance here, but what are you doing to make it happen? Which language are you pushing?

OBD2

XCmaner on October 26, 2012 1:45 AM

Given Facebook's long term commitment to PHP I think you may as well forget the possibility of it fading into obscurity.

Evanmcdonnal on October 27, 2012 10:36 PM

I've had absolutely no problem coding in PHP, I think the problem may just be bad or lazy programmers who expect way too much out of a language and not more from themselves. Also there's too many articles written about 'how bad' PHP is while not explicitly outlining examples or providing solutions.

Foxtrot Sierra on October 30, 2012 11:52 AM

Honestly PHP is not that bad. I find its flexibility quite good. What the article comments about needing a shoe or a bottle as being a disadvantage I say is actually an advantage in that it gives you many options to do something. Don't have the right tool? Build it.

I will say that PHP in the last year has gotten worse however in that they continue to try and introduce new features that just aren't part of the PHP plan in the early days. Traits? Really? They should have just enhanced the functions they had and worked on simplifying things instead of adding new stuff.

Shital Thakker on November 1, 2012 6:04 AM

PHP is so convenient sometimes... I never runned into any sort of mathematical operation regarding date and time that could not be solved by using only 3 functions: date, time and strtotime.

Java, on the other side... I spent days reading javadocs for loads and loads of Calendar, JulianCalendar, GregoryCalendar, MayanCalendar classes... having to use special classes for date parsing and converting back and forth from numerical to text data types... made me almost smash my head against a wall.

In .NET, it was just fine... until it started to apply internationalization, time zones and etcetera to my calculations without I asking, and without even giving a warning about it.

Sorry about the bad English.

Leda Ferreira on November 1, 2012 7:24 AM

I wonder about people that post things like this. I also wonder about people who talk about MVC frameworks, and say ridiculous things like "this one framework is preferable to another because it holds me to mvc better." Truly, hearing it over and over and over again really makes me shudder.

Same is true here. Everybody likes to bitch about how poorly designed PHP is. And if they were actually taking issue with the design of the language (it's a legitimate gripe), they would have a point. But then they do one of two (usually both) things.

First, they provide a lot of pissy memish pictures with no concrete actionable information, and say the whole thing's crap. Then, they'll start flapping their lips about how bad other people's code is.

But, you see, that's not an honest argument. Either way. As a programmer, it's your obligation to complain about other people's code no matter how great it is (unless it's perfect). And that goes for any platform you work on. Convincing clients they've been hoodwinked, and that they need a complete re-implementation is a consultant's bread and butter. Sad but true.

And yet, it's not really an argument for one language design or another.
Is the problem that php lets you get away with writing such bad code? Is the problem that a lot of the big projects like CodeIgniter, Magento, Wordpress, Drupal, and many many others just really suck to work on?

No. Of course not. The problem, as stated is that php forces you to build upside down houses with doors that fall off. Totally against your will, too! Listening to this guy, you would almost think that there's no possible way any competent programmer could ever build a sensible piece of code in php because php is so poorly designed that no sane programmer would ever even try to do it.

All the while, no real complaints, other than he can't figure this or that or something else out. That's not the fault of the language either. Willful stupidity, and intentional ignorance are never the fault of the language. And neither are grandstanding trite blog posts with no real content.

That's all I'm sayin.

Later.

Moshe on November 4, 2012 6:46 PM

index.php...




name
username
A B C D E F G H I J
select password pattern
from above string
dob
email


already registered
login here




===============================

register.php



$name=$_POST['name'];
$pattern=$_POST['pattern'];
$username=$_POST['username'];
$email=$_POST['email'];
$dob=$_POST['dob'];
$flag=true;
$password_pos="";
for($i=0;$i {
if(preg_match("/$pattern[$i]/","ABCDEFGHIJ"))
{
$password_pos.=strpos("ABCDEFGHIJ","$pattern[$i]");
}
else
{
$flag=false;
break;
}
}
if($flag)
{
// echo $password_pos;
require_once("db.php");
$query="insert into user_data values('$username','$name','$password_pos','$dob','$email')";
if(mysql_query($query) or die(mysql_error()))
{
echo "registration successful login here";
}
}
else
{
echo "pattern mismatch....please select pattern from string only";

}

?>



=================

login.php





username
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
$str="";
for( $i = 0; $i <10; $i++ ) {
$str .= $chars[ rand( 0, $size - 1 ) ];
}
echo "$str";
?>
password
/>



=========

validate_login.php



$username=$_POST['username'];
$password=$_POST['password'];
$random_string=$_POST['random_string'];
require_once("db.php");
$query="select password from user_data where username='$username'";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
$saved_pattern=$data['password'];
$entered_pattern="";
for($i=0;$i {
$entered_pattern.=strpos($random_string,$password[$i]);

}
if($entered_pattern==$saved_pattern)
{
echo "login success";
}
else
{
echo "login failed";
}
?>


==================

db.php

$con=mysql_connect("localhost","root","");
mysql_select_db("blazeclan", $con);
?>

Ramu Baba on November 7, 2012 7:05 PM

///form action="register.php" method="POST">


name
username
A B C D E F G H I J
select password pattern
from above string
dob
email


already registered
login here

..................
$name=$_POST['name'];
$pattern=$_POST['pattern'];
$username=$_POST['username'];
$email=$_POST['email'];
$dob=$_POST['dob'];
$flag=true;
$password_pos="";
for($i=0;$i {
if(preg_match("/$pattern[$i]/","ABCDEFGHIJ"))
{
$password_pos.=strpos("ABCDEFGHIJ","$pattern[$i]");
}
else
{
$flag=false;
break;
}
}
if($flag)
{
// echo $password_pos;
require_once("db.php");
$query="insert into user_data values('$username','$name','$password_pos','$dob','$email')";
if(mysql_query($query) or die(mysql_error()))
{
echo "registration successful login here";
}
}
else
{
echo "pattern mismatch....please select pattern from string only";

}
...................

username	
php
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
$str="";
for( $i = 0; $i <10; $i++ ) {
	$str .= $chars[ rand( 0, $size - 1 ) ];
}
echo "$str";
?>
password	
			/>
	

.............
validatelogin
$username=$_POST['username'];
$password=$_POST['password'];
$random_string=$_POST['random_string'];
require_once("db.php");
$query="select password from user_data where username='$username'";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
$saved_pattern=$data['password'];
$entered_pattern="";
for($i=0;$i {
$entered_pattern.=strpos($random_string,$password[$i]);

}
if($entered_pattern==$saved_pattern)
{
echo "login success";
}
else
{
echo "login failed";
}

Ramu Baba on November 7, 2012 7:09 PM

«Back | More comments»

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment