logo
Header graphic 6 of 8

Read more

External links

More

Last update: 02/21/2008

Comments for: I’m sorry, but PHP sucks!

Please note: Comments made before 02/22/2008 were made regarding a previous version of the article. Between 2006 and 2008 I made only minor changes to the article. You can read more about the changes that I made here.

44 Responses

  1. SitePoint Blogs » A pro-PHP Rant

    […] OK—following on from here and a later comment from Tim (and in fact more this rant from Jonas Maurus); How about somebody sends me some good pro-PHP rants? […]

  2. Reality Me » Another Anti-PHP Rant

    […] Another person frustrated with PHP. Oh how I love ColdFusion! […]

  3. PHP — Good or Bad? | FuCoder.com

    […] First of all, Jonas Maurus wrote “PHP sucks”. It’s a bit technical, but I very much agree with what he has said. There are simply too many “warts” in PHP-land that can catch even a seasoned developer by surprise. For example the pass by reference difference between PHP4 and PHP5, and you usually need to use === (3 equal signs) to correctly validate the value as boolean false. […]

  4. Kapusta Brothers » Blog Archive » Best and Worst of PHP

    […] PHP Sucks  […]

  5. Paul Goscicki » Blog Archive » Yet another anti-PHP rant

    […] I’m quite surprised to see this great stir in the blogosphere caused by Tim Bray and his essay On PHP. I mean, what’s the deal anyway? We all know that PHP is a lousy programming language. So instead on focusing on the big picture and trying to list as many of its faults as I can remember, I’ll stay on one specific problem, which is really a pain for me. […]

  6. A TechGeek’s Blog » Blog Archive » Why PHP sucks?

    […] Jonas Maurus gives you 6 reasons why PHP sucks from not so being easy to install to PHP’s character-set support. php programming reviews […]

  7. Jonas Maurus’ maurus.net » Typo3, PHP, MySQL connections and Unicode

    […] I have said it before and now I have to say it again. […]

  8. Jonas Maurus’ maurus.net » UTF8-encoded Unicode support

    […] PHP… don’t even get me started. PHP just sucks. […]

  9. Jonas Maurus’ maurus.net » New features

    […] I tend to clutter my articles with lots of notes that are important to create context, but might turn a reader away. So go and meet the new hide-the-notes button. […]

  10. Peter Wolfenden

    My own list:

    1) In a language intended for developing web applications, the absence of basic security features (like Perl’s “taint mode”, for example) is absolutely inexcusable.

    2) The convenience of having lots of built-in functions (like print_r() for example) is in my experience outweighed by the outright bugginess of many of these functions. For example I tried to use the var_export() function in PHP 4 as part of a code-generation tool earlier this year, and found that it produced invalid PHP code quite often (I ended up writing Perl scripts to generate my PHP code).

    3) My experience trying to write text parsing scripts in PHP has been awful. I laugh when PHP programmers complain about the unreadability of Perl scripts – just getting a nontrivial regular expression to work with preg_match() is enough to make me pull my hair out.

    4) I’m not even sure how much I can legitimately complain about ADO db. Maybe it sucks, or maybe it’s the best you can do with PHP?

  11. Vahrokh Vain

    Visual Basic is a total piece of crap.

    COBOL? Even worse.

    PHP? A C kind-of interpeter usable as CGI that outgrew itself into the current “form”.

    C++ itself, has humble origins.

    What do the above pieces have in common?

    It’s stuff that even a barely trained monkey understands and fast.
    It’s stuff that lets you achieve “something visible” in a fraction of time.
    It’s stuff you don’t need to be computer literate to use.

    Basically it fulfills the “80/20” law (80% done with 20% of effort), fast and decently well. Decent enough that those who pay for it won’t know it’s not computer excellence.

    So, this stuff wins over elegant Java hierarchies, over UML studies, over by the book computer engineering.

    You can’t say this stuff fails or sucks, because the world runs on it. If it failed it’d be confined to the original author and a circle of “fans”. If it sucked it’d reveal to be an hype bubble and burst in few months.

    Now, the style of that stuff is not elegant nor didactic, the same can be told of PERL regexp protecting organizations from being hacked. Quick and dirty started with MS-DOS and GW Basic and proved to work and fast, which is all what those who pay care about.

  12. brock noland

    You have many good points. However, I would note that php being dynamically typed has nothing to do with this abomination:

    (string)”false” == (int)0 is true

    It is weak typing which causes this craziness. Read more here: Typing: Strong vs. Weak, Static vs. Dynamic.

  13. Tim Cook

    No, this is just PHP. Try that in a Python interpreter. It is False.
    >>> “false” == 0
    False
    >>>

  14. Agent Ultra

    […] now when it is so common place and robust else where. PHP as a language still has a long way to go. The only thing keeping it going may simply be the footholds it has managed to entrench itself in. […]

  15. brian will . net » Blog Archive » Piled Heap of Poo

    […] Anti-PHP screed #34019. For those of us who’ve only glanced at PHP, both interesting and distrubing. […]

  16. Jason

    I’ve had trouble too with PHP comparison operators, specifically with NULL values. I also hate the fact that certain functions are inconsistent across operating systems. I still feel that PHP has its purpose despite the quirks and limitations. It seems to make a pretty good blog (wordpress) and wiki (mediawiki).

    For more truth tests you should check out this cheet sheet.

  17. Vincent

    If PHP sucks, what else do you suggest that makes sense in a business context?

    Python: You can’t find any employees that write Python and the deployment is still painful.

    Ruby (on Rails): Does not scale, every .X version is incompatible with the previous. You still have to problem to find anyone who writes Ruby.

    Perl: Not really a Web technology, it is a pain to make it work.

    ASP.NET: Tied to Microsoft servers and technologies.

    Now, what else do you suggest?

  18. Jonas

    @Vincent:

    Without knowing anything specific about your needs, I would recommend Python for most web development, which has its own problems, of course, but not the amount that PHP carries around.

    In a “business context” I’d say that Java (with Grails or Tapestry 5) can be a solid choice that also gives you a good chance of finding developers if you need to scale your team.

    I’d also argue that PHP with all its incompatible versions has far more deployment problems than Python. Still, both lack tools that are comparable to Capistrano or JEE deployment tools. There’s some work being done, but chances are that you’ll have to roll your own.

    But, if you’re searching for someone who gets into your office and you can have them sit down and write code: you’re right as well. There are far more bad PHP programmers out there than bad Python programmers, because PHP is easier to get into if you have no “formal training” (in my experience, the missing namespaces come in handy there) and these people then show up in your office via various “body-leasingtemporary employment agencies the moment you need to get something done quickly.

    So in my opinion, PHP allows you to shift a lot of “before-development-starts”-costs, like careful team selection and team education and implementation planning to future maintenance.

    All the options you have, present you with different trade-offs: the amount of “code-writers” you can hire quickly, average programmer productivity, average code-quality produced, amount of maintenance spending necessary for platform upgrades, amount of support you can get, amount of time you need for your first prototype and so on.

    It’s also important to recognize that these factors vary depending on what country you’re living in and in which industry you’re working, so you’ll have to figure them out on your own.

    In my opinion, it’s just incredibly important that you make a platform decision with open eyes.

    If PHP matches your needs, by all means, go ahead and build on it. Just make sure that you take all necessary precautions and assign someone to be responsible for compensating for the problems I described in the article and really really really resist the urge to talk them away (i.e. “Let’s not care about it, nothing will happen because of it”, also known as the Rails-Community-Credo), because all these problems will come flying and hit you in the head.

    But I’d give you the same exact advice if you were starting a Java project or an Erlang project or anything else.

    Unfortunately there’s no silver-bullet and there will never be one. My main concern with writing “PHP sucks” was making clear that PHP isn’t one either. If you want my input on a specific project, just send me an email :-).

  19. Alexander Kesadavich

    No human mind can guarantee the delivery of quality work. In the software development world this is absolutely true for computer science educated minds as well as minds lacking any formal computer science education. However, if you are in the business of constructing and delivering quality software solutions you try to stick with minds formally trained in computer science at reputable, verifiable institutions. Usually… groups of individuals with this kind of background will choose the correct technologies and methodologies to develop and deliver excellence oriented quality software solutions. Even if destiny has locked you into a poor technology choice like PHP, talented individuals with a solid CS background will usually make the best of the situation and steer projects in the best possible solution within the given poor technology constraints.

    Alexander Kesadavich

  20. Alexander Kesadavich

    The point being in my last comment that as many of you correctly point out in your comments: the problem in software development business is commonly less of a technology problem and much more of a people problem.

    Alexander Kesadavich

  21. wahyu

    ASP .Net is my choice. C# is a mature languange, strongly typed, compiled language (faster in general), OOP. After .net 2.0 all upgrade after that had caused no compatibility issues. The upgrade to 3.0 and now 3.5 were about adding more great features: WCF, WPF, LINQ (wooooooooowwww LINQ). Knowing C# means you can build web, silverlight, wpf, mobile application. Create libraries in C# and use them for all those kind of application. Visual Studio 2005/2008 is the greatest IDE tool available, if you want a free one? get the Web Developer Express, compare it with any free tool. I love the code hints/completion. Why bother if it is tied to Microsoft? there are some hosting available starting at $5. You can also use MySQL.

  22. Weekly linkdump #128 – cb – блог разработчиков

    […] Свеженький холивар, на этот раз досталось PHP: I’m sorry, but PHP sucks! » Jonas Maurus’ maurus.net […]

  23. james mckay dot net » How to become a better .NET developer

    […] PHP as a learning exercise: it is a beginners’ language — and a mind-bogglingly badly designed one at that — and while PHP guys are generally pretty enthusiastic and some of them are quite […]

  24. PHP sucks, no wait it doesn’t , who cares! | 24 Hours is not enough

    […] of talk lately about whether PHP sucks or not, in fact its not a new debate at all. A lot of people say it sucks, a lot of people say it rocks, so which side is […]

  25. PHP+ZF+ADOdb+YUI = Easy Web Development | PatrickMD.net

    […] predict what code will do with unexpected values. I was going to write a post just about that, but Jonas Maurus has a well-written explanation of the design problems with the […]

  26. Lemur

    I don’t really agree with you on the statement that PHP sucks. You have listed out some of it’s problem points, which the PHP devs will have to look into, but as far as scripting languages goes, I find it the most appealing language I’ve used before. I’ve worked on ASP and PERL, attempted to learn JSP but got annoyed with it’s server configuration issues.

    None of the issues that you have stated really affect me, but it’s nice to know.

  27. Michael

    Every language has it’s downfalls, but I personally believe that PHP has too many. I’m an experienced programmer and just looking at PHP hurts my eyes. Nothing in it makes sense to me besides it’s ability to perform web tasks easier. (such as databases) Sure it might be a good language for beginners, but those new programmers are going to have a VERY hard time learning any other “structured” language.

  28. Antagonist Prime

    You missed one other important point, the pay sucks!

    Here in the UK there is a £10k difference between PHP and ASP.NET, I’m sure people at the top end are earning good money but the average developer is getting shafted. The issue doesn’t seem to be the employers, they love the low wages don’t get me wrong, it’s the developers, they seem to take great pride in earning less than anyone else.

    I can’t speak for anyone else but personally, I’ve given up on PHP and moved to the dark-side, at least now I can pay the rent.

  29. Dave May

    What bothers me most about PHP is:

    “0” == false (oh my god)

    where these are CORRECTLY true:

    ” 0″ == true
    “0 ” == true
    “00” == true
    “0.0” == true
    “” == false

    Non-empty strings should be predictably considered true.

    At least it should be predictable. And sadly PHP developers think they are right, even though their language goes in unusual and non-workable directions. Their argument? “It’s a web language, not a general scripting language.” What does that have to do with interpreting boolean values of strings?

    And so on. PHP is ghastly.

    Dave

  30. eden

    Hi

    Facebook uses php, doesn’t it count as a large project?
    Anyway, there is something I would really like to see in such an article – the future. It is obvious that the free open-source style is here to stay (or am I wrong?)

    So, is there a good replacement for PHP considering all the effort done in open source (Drupal and such)?
    I’m not talking Microsoft.

  31. Xeross

    @eden: Facebook has 30k server due to poor PHP performance, and well rewriting it in another language would require a huge investment in both time and money, and I doubt facebook wants to invest that in a rewrite.

    Now I was wondering, what are the alternatives, I could ofcourse write the entire app in C++ but using C++ as a website system feels stupid + I need to run every site on a different port.

  32. Justin

    1.“PHP makes it easy to get things done for a beginner”
    2.“PHP is easy to install”
    You’re right these statments are true. But it’s another reason why it sucks.

  33. thedoublefinger

    Great article, with most stuff here that I did not even know about.

    Obviously PHP has got some lacks, here and there (“and there, there, here and there!”, would you say) but I still think that, and you could apply this to almost any actual language, it’s a matter of point of view, habit and need.

  34. Denis

    Thanks for the good article. after an intensive working week I’ve just had one thing on my mind “php sucks” – I typed it into the google search box and landed on your blog. A quick scan through the points you mention here (although I’m not a php developer at all) just made me feel much better thank you. for those who’se asking what else is there to use I’d strongly recommend c# and asp.net – not the beginner level, etc but have some real extensive experience and you would know what I’m talking about.
    for #17 (Vincent) – why do you start listing the options from all the alternative crap like python and ruby ? you just ought to be different ? I’m also pretty tired of browser incompatibility – each one does whatever it wants to … :) Just making a web developers’ life harder.

  35. Mittens

    My experience is that PHP is a pain to install BUT once installed it is rather easy to use.

    I managed to avoid PHP until PHP 5.2 and even wrote my own scripting language. Wait…have YOU ever written your own scripting language? No? Then until you know how damn hard it is, you really don’t have much say in the matter.

    Anyway, around PHP 5.1 is when I saw the language mature enough to consider it to be usable (i.e. had more functionality than my language). The performance differences between PHP 4 and PHP 5 were also significant.

    The alternatives to PHP 5 are: My own scripting language (I’m not kidding – I wrote a scripting language similar to ColdFusion – performed better too), ColdFusion, Ruby, Python, ASP[.NET]/C#, Perl, and writing CGIs in C/C++. (Who the heck writes COBOL for the web?)

    Here’s my summary of why I don’t use each one in respective order: Slightly buggy, buggy and a huge resource hog, slower than molasses, PHP serialize() works fine (serialization touted as Python’s big benefit) and poor performance and forced code layout, proprietary and buggy, have to relearn it every time I try to use it with crappy variable scoping rules, doing that is just asking to get hacked, and…what the…COBOL?!

    Every single “weakness” in this article is more a nuisance than an actual issue. Every scripting language has certain weaknesses because they try to abstract away from the hardware. Which is actually a good thing. The Unicode issue is the only major _bug_. BUT, I’ve also worked extensively with Unicode. Joel Spolsky is a moron when he says Unicode is easy and that article he wrote has every developer convinced that it is. It isn’t! Correctly manipulating Unicode strings is VERY, VERY hard. I should know: I’ve also attempted to write a Unicode library from scratch. I hit collation and stopped working on it shortly after that. I know more about Unicode than most developers who work with it and there has yet to be a completely functional implementation of Unicode created. If you think PHP “sucks”, try Unicode.

    Perhaps every web language’s greatest weakness is security exploits. It isn’t just PHP but every language. It has a lot to do with people writing code in scripting languages who don’t know how to write secure code and are just throwing together quick bits of stuff.

    Also, my experience is that most developers just use PHP for ‘include “header.php”;’ and ‘include “footer.php”;’ so they aren’t replicating the header and footer code statically across a site. Very little out there is truly dynamic.

  36. About PHP « Dinu Florin

    […] more about the topic: I’m sorry, but PHP sucks. and PHP Sucks, But It Doesn’t […]

  37. Rusty Shackleford

    PHP: Unsafe at any speed.

    I can confidently say that PHP is unsuitable for any and all tasks.

    It is also the only language where a rewrite actually makes sense, and is worth the cost to do so.

  38. theOOGuy

    Great article! PHP might be hard to install for some but the thing I remember the most is that it’s spaghetti crap all the way and is an environment in which it’s really hard to apply real OOP principles, and as those PHP frameworks that tend to be a bad copy of RoR, all I can say is could luck but you should use another language first

  39. jack

    i’m a .net developer but my company is using both, .NET and PhP, so was forced to adapt to PhP as well, but I love .net, i built multi-threaded applications into it, but in PhP, there’s so much work around to achieve similar feat, yet not even close to .net multi-threading.

    my opinion, go for .net, there’s also mono that allows you to run .net in linux, but if you’re working on a company, and using a language is being enforced, you’ve got no choice but to stick with the company’s preferred programming language, or leave the company and find one that are using your specialty.

  40. Elliott

    Lawyers create laws and they structure them in a fashion that is ever more obscure and incomprehensible; this ensure their services are continually required to interpret them (also provides the necessary loopholes for politicians which are almost all lawyers themselves). As softwares are becoming easier to operate(at a beginner level), I can sense fear that software engineers believe their industry will go the way of the dodo. In my mind, easier to use software are good to recruit the new generation of developpers which now have tools to create something more interesting than what was available with Logo back in the 80s. As it has been mentioned in previous posts, software engineers have the training to choose the best applications for the task at hands; they also have the knowledge to deal with the limitations of software should they be forced to work with less optimal solutions. Technology is developping rather fast and will be constantly moving. Backward (and forward) compatibility is obviously important to maintain very large-scale projects but I know for a fact that large corporations rebuild completely their systems every so often (let’s say a decade) when the advantages of the new technology outweight the cost associated. Languages like PHP, Perl, Python and others are improved on an ongoing basis by a very active community; they will continue to get better and most of their flaws will be dealt with over time. They may have their problems at the moment but you need to walk before you run. Finally, learning a few functions of an easy to use language is a far stretch from reading all there is to know about proper software structure, scalability and security. They are perfect for someone wanting to build a personal website but probably not what is needed for a multi-national company. One has to remember that most of these languages emerged as a solution (read utilities) that some programmers developped for their own usage. Each new version of these languages try to add the neat functionalities of other languages until they reach a point where these languages are again very vast and complicated. Then a new group of easy and simple languages emerge again and the cycle start over.

  41. Seriously, stop using PHP | kolizz

    […] like about PHP. It covers some of the biggest problems with PHP. You should also read the article I’m sorry, but PHP sucks over at maurus.net, which also covers some (other) of PHP’s biggest […]

  42. PHP vs. Python – Projeckt

    […] I’m Sorry, but PHP Sucks […]

  43. Jon

    I love these arguments! Truth be told, even though I am a PHP developer, this article is complete right. I also think the Pro PHP post the author references is correct too.

    http://blogs.sitepoint.com/2006/02/21/a-pro-php-rant/

    So what I think it comes down to is both these are right. However, in consider the following quote, used in the open paragraphs of the article:

    “based on my limited experience […] all the PHP code I’ve seen in that experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places”.

    PHP is a tool, and the work produced using such a tool is only as good as the person who wields it. I personally think therefore PHP developers need to up their game when using PHP. PHP allows you to be really really sloppy when it comes to coding.

    There needs to be some kind of standard that PHP developers adhere to, to rectify this situation. Not just coding standards, but an approach that developers using proper programming languages commit to day to day.

    A couple of examples:

    – Any warnings are errors. Use E_STRICT and E_WARNINGS in development.

    – Get as close to strong type coercion as PHP currently allows, for example, use of type hinting to force parameters to objects or arrays, do not exploit weak typing, use isset.

    – Code defensive when dealing with user entered input – always assume user input is trying to exploit some security vulnerability.

    – Document your code!

    etc. etc.

  44. Denis TRUFFAUT

    Put sessions in memcached and you will avoid problems.

    The real problems with PHP are a no-native support of UTF-8 in its internal string representation (Planned for PHP 6), a very basic fork/hyperthreading (prefer shell threading with shell_exec(‘… &’) and some ‘ps aux | grep … | grep -v grep’ to retrieve childs) and some memory leaks with file reading cleared only at the end of the script.

    For every else, it rooooocks !

Leave a Reply (comments are moderated)