So... today is kind of slow at work and I decided it is my turn to say why PHP sucks. Spoiler alert: You will not learn anything new here, because I just summarise what others have said.

Honestly, I like PHP - it was my first language (after bash) and I am used to it. I know how it works, how to work it and why it is a health hazard. Objections such as the string function signatures and signatures or the array functions are inconsistent and the return values are random are valid, but you deal with it. If you are a total rookie, then unpredictable runtime parameters caused by (morons) changing php.ini-directives could be surprising and annoying, but there are only so many of them and I prefer flexibility because it is powerful. Require hell was addressed with auto-loading.

The list goes on, and personally, I can live with most of the flaws;

  • Keywords may not be class properties in 5.x => expand your vocabulary
  • PHP 4 is garbage => don't work for people who use PHP 4
    • return &new Foo(); broken => use sed.
    • 4 is incompatible to 5 => boo-hoo. rewrite your crap.
  • no threads => threads lead to shitty code anyway
  • some functions do not exist on windows => can not care less
  • non-standard (UNIX/C) date-format characters => deal with it
  • Magic quotes hell => not hard to enable / disable
  • No unicode => python and perl had the same problems
  • whacky == operator => learn the rules, use them.
  • single-threaded sessions => use something else for sessions
  • No frameworks => I give up.

Almost none of the above are hard, unsolvable problems if you work with sane code and disciplined programmers, but the real-word case is you almost never do. Even if you are, the managment will virtually never allocate time to clean old code and clients will certainly not.

My first two years with PHP were in WordPress and during that time at one point I spent two weeks writing a 20-page article, with graphics, explaining to my CEO and a consultant from a WordPress-based company, why our CTO should not have picked WordPress as our "platform".

In my 3rd and 4th years with PHP I am dealing with applications that have been growing over the span of some 5-10+ years. Some of the developers involved worked on them for the whole time, some for half the time and some even less.

What I find trully surprising is that none of them took the time ever during those months or years to tell the management - HEY! We need time to clean our own or others' crap before adding more unplanned features to avoid ending up waist-deep in a pool of sewage. Clients may not care, management may not care, but as a programmer, you have to care!


Some fun/sad links:

PHP: a fractal of bad design

Integers in PHP, running with scissors, and portability

php-cheat sheet == and ==
-- careful, their php-syntax exam is based an old PHP version.

A pro-php rant

Experiences of Using PHP in Large Websites


typo3, php, mysql connections and unicode

(post) In which I write about PHP for the first and the last time

Jepper's Unicode page


Previous Post