Visit What I don't like about PHP.
"Magic quotes prevents PHP-scripts from SQL injection attacks. That's okay."
Like hell they do.
Fist of all Magic quotes will only work for some DB engines - for other they will only make you more conversions.
Secondly it will only work out of the box if will read and write almost directly from the user.
If you will input/output directly you will have no control on the input which is even worse then just SQL injection.
They are really truths, because we cannot make fork? I started well to use kargo-events in the place of the apache/nginx, twirling to the style of rails, have given right.
Dang. What's with the horrible spelling? It really undercuts your logic -- compair? Populair? Answeres? I agree with most of your points, but Unicode is not a trivial feature.
Random Visitor, I couldn't find the word compair, but I fixed the other two "horrible" spelled words. You might have guessed English is not my native language.
I agree on this article..
JSP ( i used back in 2003 )was much better and easy to manage with components, and secure though..
ZERO 360 Web Technologies
I agree with you at all points. But the problem is that PHP is accepted in more and more companies. I'm currently working as a PHP-programmer, too, to earn some money besides university. I would like to see a sane PHP version, but this is an oxymoron, so spent I spent my time in learning haskell and use happstack.
I agree with most of your article except a few points.
* How is Zend the only "real" object oriented framework? I've read some of cake and it looks like it's using "objects" to me.
* You say "Until then, when you start a project larger than five scripted pages, you might also consider C#/ASP.Net or Java/JSP as a better solution"
UMMM EXCUSE ME?! I'm currently working on a very large project in PHP that is WAY larger than 5 pages and runs just fine (without hardware performance additions). And Python, Perl, or Ruby could use a mention from you as well.
John, PHP has become really object oriented since version 5, so any framework supporting PHP 4 can't really be object oriented.
Maybe five pages is a bit exaggerated, but you get the point.
Python, Perl, or Ruby are nice languages, but unfortunately, they're all very slow.
..C#/ASP.NET and/or Java/JSP/JSF both have to startup a virtual runtime. Ever tried running a Tomcat on a 256MB RAM machine? Forget it, it just runs out of memory after you deployed a single container. The very same server however runs more than 100 websites and ~500k requests/month - to hell with PHP doesn't scale well. Your calculation on the 30k Facebook servers is quite funny. "They also use 30 thousand servers. That's a lot. If you do some calculations, you'll find out, on average, one server handles only 104 visits per hour". Short: WTF!? Long: Do you really think all 30k servers are running a webserver? Ever thought of how FB stores data? Exactly, you need servers for this. Probably 98% of those server are for storage only and build up a huge CDN for all the images/videos/text/crap that users share.
As bad as Java the language is, Java the platform is outstanding. performance almost always takes more memory. See memoization.
Is it a good tradeoff? It depends. On the web the network is the bottleneck and quite often increasing performance in a web app buys you nothing. If a web page can be fetched in 20ms but the round trip time is 500ms and it takes the browser 50ms to render it, increasing fetch time does nothing but buy you a few extra hits per hour.
All that is moot. PHP has nothing positive to offer. Ease of learning and usage is not a plus. It is the reason so many PHP sites are an amateur hour mess of spaghetti code, SQL injection, and XSS.
PHP doesn't scale, it is probably the worse designed language created for widespread use. VB is miles ahead, and VB sucks.
PHP makes it really easy to do the wrong thing, but if you want to code correctly it puts lots of hurdles in your way.
PHP: unsafe and unusable at any speed.
Who should use PHP? Nobody!
I tend to agree, particularly after learning c# last year. I am developing a large php program (for legacy reasons only), and added to your list are the arithmetic problems where using decimal and floats sometimes create false unpredictable results, therefore I would not recommend php for any financial code. I have also run into a few issues with type safety and you are left wondering why the php function does not work, and it is down to type safety, I think this is a mistake having loose types. That said, my new program works great but given the choice, next time its dot net.
Mark of Sydney
@ Edwin MArtin
Python is slow? When compiled, it is "significantly" faster than PHP. I would reconsider revising your sources.
I don't know but maybe I'm a really good PHP programer because I've done things really amazing with PHP and I haven't had so many problems using PHP as this article pretends to say It could be lol... some things like picture manipulation, automatic recursive menu generators, all kind of database transactions, etc, etc, etc.
By the way I work in an university, We have 25K new student per year and all they have to register online and we have ZERO data errors due to PHP however I'm not going to say PHP hasn't defects but I think that the most important thing is the programmer than the language, bad programmers will be bad in any language.
Well I hope You can understand what I wanted to say, I'm not a native english speaker but I wanted to tell You my experiencie using PHP. Bye.
PHP absolutely sucks but a shared-nothing architecture makes a lot of sense. Sharing data in memory across multiple threads or processes is a very difficult thing to get right.
What the lesson is - use the right tool for the right purpose.
To build an entire app in PHP is stupid - to build and entire anything in one language is stupid. Java/C# are brilliant a the big beast back end systems. PHP is brilliant for a lightweight front end. Don't be scared to mix and match and use an API - if something is slow you can always change the interface later. In fact, you should always be looking at using an API / data mapper layer.
PHP can be very fast if you use hiphop - it's what facebook do. Java is fast... once your already got enough power to run the runtime monster. C# is (mostly) an iis platform, a no go really. Python is a good alternative.
Naming convention in PHP does drive me made, but surely that's what IDE's and the web docs are for? I think they need to be firm with PHP6 (which is on hold and now going for 5.4) and sort our naming conventions.
I'm surprised you didn't mention the SPL - makes life much easier!
Some interesting stuff - but many experienced master PHP developers, at my work place, will disagree as we have built some serious web apps using PHP. John http://www.rapidsoftsystems.com
I've built huge apps in PHP that scale; the key is using a good framework. Out of box, CakePHP supports caching, sessions stored in the database, and OOP, so it scales incredibly well. Sure, there are some php guys who give the rest of us a bad name, but a good php developer really can program great, scalable systems using php and mysql.
I was curious to see if it was PHP the language or PHP the framework that really sucked. So, as a bit of a lark, I built a PHP View Engine for ASP.NET MVC.
So, now you can recommend PHP/ASP.NET as an alternative. :-)
What about VB? Just kidding. I'll leave now.
"PHP has two advantages: it's very easy and it's widely supported by webhosting companies. But that doesn't make it a good language."
Actually, that's exactly why PHP is such a prolific language. That's what makes it good. That's what makes it so wide-spread. That's what makes it so fast to code with. That's what makes finding developers for it so easy.
Remember, the business choke point these days is NOT the speed of the code and computers. It is the time it takes from zilch to market, and that means the time it takes a programmer to create a solution. PHP is amazingly fast at this. And incredibly flexible there-after. It is this as-you-go optimization potential that makes it the go-to language for so many start-ups.
PHP is also the cheapest platform. Which combined with the other attributes is a force to be reckoned with.
That said, everything you mention about the language that are negatives are real negatives. But thinking that they will prevent anyone from adopting PHP shows a misunderstanding of how platforms evolve.
Anything done to try to fix these problems for the long term, will make the language harder to pick up in the short term. Which means less people will. (Aside from naming conventions, which work to create a culture of people who are always looking in the docs, which means always finding new features) It is basic Natural Selection that has led to PHP being popular.
I agree with some of the core issues, like not being thread safe and Unicode support. However share-nothing architecture objection does not count for much when you consider that most important use of PHP is to generate
web pages. Heck, which language has an nl2br routine? No one is trying to write their next web server in PHP, yet!
Bad Unicode support is a pain though. However I do not agree with "slow" comments. I do not know who coded a page to use 15 MB. That is just bad design. Some of the biggest systems on internet run on PHP (wordpress/FaceBook) and there is reason behind that. Do not equate stupidity of PHP programmers to that of PHP.
Any real language and platform is messy. Just think of how messy C would have looked to Lisp hackers. Perl is messy and so is C++. A language, framework or platform is no guarantee to better code and products. Most of the time the guy using them matters more.
If this page contains 100 opinion says PHP is bad, we have billion of site written and working with PHP, non of them says it a bad solution.
As you say, Facebook, if its that bad I'm certain FB will not be so adventurer to be in that danger with PHP.
If PHP that bad, can I believe your opinion and disbelieving in billion others???
I think those says php is bad just feel Jealousy from php.
Every one said their opinions,and above said all are true and PHP has over come some of them,and also going to be in PHP 6,and Java hasnot build in a single day my friend.
PHP sucks primarily because its not compiled and has dynamic typing. I work on it everyday and I hate it. I cannot organize my code well with it, because everytime I want to I have to think about how it will slow down performance. This is a serious reason why PHP must die. PHP is OLD FASHIONED. We have outgrown it. Let's move onto something better, and please let it be compiled. ASP.NET, Java Servlets, anything is better than this crap.
As far as I know PHP is a scripting language, not a programming language. The article keeps claiming PHP is a programming language, while it isn't.
@TGY: Why is a scripting language not a programming language? PHP is a very real programming language.
@Edwin_Martin PHP may have gained its popularity over time and become very function rich so that people compare it with other real programming languages. However, it started out as a scripting language to change a-little-bit-this-and-that in HTML pages. Now, it is the most overgrown and messiest scripting language on the planet.
Some of the comments harvest their own misery:
Php can be made fast: It requires extra work, why not choose a fast solution right away?
Easy to find php developers: Well good developers are equally scarce for every language (and usually don't like PHP).
Faster to write php code: Get a savy functional programmer and I bet he can come up with cleaner solutions using less code and time.
Big sites use PHP so it scales properly: Sort of biased, most big sites do a lot of hacking and customization to the php platform so it scales properly (FB even has it's own php to c compiler). With enough effort any solution is scalable. The thing is that there are platforms that scale with very little (or no) effort and PHP for sure isn't.
After reading Rasmus' Q & A and just from general PHP experience you come to realize that PHP is a noobs language. Although, it solves a problem and so has a purpose. The point of PHP seems the ease of use factor wherein a person can create an interactive site easily. Granted if you want scalability you should consider Python but then again Python won't be as easy to setup and wasn't designed to solve the problem of the web. PHP has a dark side that a committed developer will encounter at some point. You either deal with it or move on.
Yeah!! PHP sucks but Java is the biggest shit, believe me!!
For me PHP is just a data delivery mechanism, same as Java or Python or dare I say Ruby. The real work in building an awesome web app or web site is in creating an awesome user experience. People who get hung up on the server side of things may be ignoring more important things.
Nice read but I found a few things that I want to put out there.
1. 2GB is not 2000MB it is actually 2048MB. Yes not much of a difference but it is one that can make a big difference.
2. Your calculation about how many requests the facebook servers deal with is most likely to be wrong. Just because they have 30,000 servers that does not mean that they are all set up in the same way. There will be many servers that will only serve images, some will be used to run cronjobs for system maintenance and ensure things are cleaned up regular, some servers will only database servers and others will probably be only mail servers. So you see if you calculate the performance of their php servers you will look actually at a much much smaller number.
Well, I love using PHP. I've just strated looking into using PHP for GUI applications and compiling to.native apps. Currently it looks great.
Of course everything will have a bad, messy and ugly part.
And when it comes to businesses I guess they care more about safety and wether or not it works than what language you used ;)
Some of the comments harvest their own misery: Php can be made fast: It requires extra work
I wanna pay tons of thanks to this blog writer.
I was assigned to create ecommerce with php so found this article and really this bloh helped me to guide about disadvantages of php .
please add one more line if you can:
A disadvantage in having query strings in url and long url. Google says it will not index urls with an id parameter.
I told all above mentioned factors to my manager and he decided to complete that ecommerce in dot net!1
Most of you "programmers" are really amazing me right here.
1) First of all, comparing PHP and Java,...or any other language is like saying "A limo is better than a Camry". IT DEPENDS ON THE REASON
2) Some situations require compiled languages while others are best suited for interpreted languages. Using java on a 5 page application in my opinion is an overkill, while trying to use PHP to create a Hosting environment is sheer madness. Apples and Oranges here...
3) Overall, PHP evolves and sometimes is forced to do things it wasn't designed to do initially. Welcome to Technology. Every language evolve. It all depends on context!
I love PHP. What I hate is too many thing is needed to move from 5 to PHP7 - missing functions are a real nightmare for anyone migrating to a newer server.
Give your comment:
The sum is to prevent spam. Type your comment below.