To view parent comment, click here.
To read all comments associated with this story, please click here.
Here is a good starting point:
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
I used PHP for years and still use it in some places where it makes sense (it's definitely one of the easiest languages to get working quickly and is super common on vhosts)... It could be worse, but it still pains me often enough :-)
This +1. It explains pretty much everything that's wrong with PHP, and there's a lot wrong with it.
dikatlon,
"Why is PHP so evil?"
s/evil/bad/
Well, having been a regular user since the beginning, I can say without a doubt PHP is superior in all ways to what it largely replaced: ASP. However that's where my praise ends. The language has suffered from inconsistency and poor SE decision making over the course of it's entire history such that the developer qualifications behind PHP are brought into question. PHP has a history of semantic flip flops creating code incompatibilities.
Ignoring the multitude of teething problems which PHP has been notorious for in the past. Here are current gripes that are often cited (in no particular order):
1. Namespace mess. This is all all the evidence one needs to officially declare the developers as certified amateurs. Also every programmer has their own opinions about whether function names should be camel case, abbreviated, underlined, etc, but at least we agree to pick one convention and stick to it. PHP is the only language I know of where standard functions have completely disregarded any kind of standard naming convention. One has to wonder whether they had any future direction at all.
2. Thread safety risks inhibit web hosts from being able to deploy multi-threaded versions of apache.
http://neosmart.net/blog/2008/dont-believe-the-lies-php-isnt-thread...
(I'd appreciate any information about whether they've finally fixed it, but it was still crashing in 2010/11)
3. Unicode.
I'm often called up by clients who find unicode glitches on a website caused by php bugs in handing unicode characters which may have been posted into the database, etc. I replace unicode characters with html equivalents, but unicode should just work these days.
4. Magic quotes.
Stupid, stupid, stupid, stupid...
5. Lack of session concurrency.
I uncovered this this year when I was trying to use concurrent ajax calls to monitor a long running process. One visitor can only have one running script per session. Apache will pass a predefined number of concurrent connections to PHP, but PHP will block them and run them serially. So, the long running process would block all further PHP pages for this visitor until the long running process was complete. This entirely defeated my intended purpose of employing concurrent ajax calls. I ended up writing a C daemon to work around the limitation.
6. Comparison operators
PHP diverges from other dynamically typed languages to use this proprietary syntax.
if (F(x)) {...}
vs
if (F(x)==true) {...}
vs
if (F(x)===true) {...}
PHP's equality personality disorder is a source of bugs and confusion. To make matters worse, we've got expressions like "x>==0".
7. PHP's documentation
Well, PHP documentation is a big plus. I thought it was superb, or so I did before php.net recently injected google search results ahead of it's own function search listings. Why did they do that?? Now I have to scroll through a screen full of irrelevant google listings before I can click on the php.net links I want.
5. is depends.
4. is gone in 5.4.
2. that isn't true.
Pretty much every extension that is support on Windows has threading support.
The problem is with all the other extensions which are not supported on Windows.
The cause is 2 fold:
1. the library the extension is using does not support threading
2. on Unix/Linux a large share of Apache users still uses pre-fork of FastCGI. Thus threaded PHP does not gets a lot of testing.
Edited 2012-10-01 12:25 UTC






Member since:
2005-07-08
Point me out, please, fellow humans:
Why is PHP so evil?