But to me, one of the most significant advantages PHP has is that its documentation is terrific. PHP.net is simple, clear about parameters and return values (as clear as PHP lets it be anyways) and best of all has a terrific comments / examples section for each function.
Better documented is better.
In fact I remember a few occasions where I’ve ended up going by the advice of the comments rather than the documentation itself because the documentation was either out dated or just plain wrong.
As for the comments. Yes. But at least they're there, and quite often helpful. Plenty of times I've read other docs where I wished they had commenting but alas didn't.
Other languages don't need comments because they at least aim to have documentation that's correct.
I'm sure the PHP documentation is getting better all the time! Other languages also have good documentation, though. And as pushpop said in an earlier comment, the reason that the comments were useful historically is that the documentation was not always correct or complete. (Perhaps in part because the the language used to have a lot more unintended quirks?)
Maybe it would help if you listed some links to language docs that you feel the rest should use as benchmarks?
I don’t really recall earlier versions of PHP being any better either. So I really don’t think PHP became popular because of the docs.
The other comments about how it was easy to learn and easy to deploy is far more accurate. If I recall correctly, back when PHP gained traction, your main options then were Perl (which understandably confused the hell out of a lot of people), ASP (VBScript / JSScipt and requires Windows NT + IIS so not a popular option) or JSP (Java and at that time was pain to deploy. So not something you’d expect a casual web developer to bother with). So PHP is like BASIC or Raspberry Pi of the 90s web. It was made for one specific job, it didn’t do it perfectly, but it was cheap, easy to learn and just about good enough to get the job done.
Really the kind of stuff that is well documented in PHP is the kind of stuff that is well documented in most general purpose languages. They are also the kind of problems that aren’t particularly hard to solve anyway.
But this is a moot point because the reason documentation was discussed was because it was credited as being one of the reasons for PHPs popularity. However tutorials wouldn’t exist if a language wasn’t already popular so your comment doesn’t reinforce the point made by the GP.
That's a good observation. Because the mod_php and mod_perl Apache modules were much faster and lighter weight than CGI-BIN, and pre-installed on shared hosting, both PHP and Perl dominated the early web days.
Might be region specific, I've mostly worked in Western Europe, but even the two NA-based providers I've used back then didn't offer mod_perl for shared hosting.
You could certainly get it on a managed server, or set it up yourself on your dedicated box, but PHP's strong suit was the low-end shared hosting options. It ran anywhere, and usually fast.
Birds are Cats.
See, we can all make unsubstantiated claims.
Just one reason is enough. I personally disagree, I think it's great.
asp locked you into microsoft, jsp was laden with heavy/expensive java app servers and semantics, and coldfusion was a paid product (and eventually locked you into macromedia/adobe).
i think that if coldfusion had the same free+paid model as php, it would have taken the place of php in web history. despite its faults (maintenance and performance, for example), it was easier and faster to learn and matched the mental model of beginners, just like html itself.
ASP 1.0 was released in 1996. The first Cold Fusion in 1995. JSP not until 1998.
Cold Fusion and PHP appear to be neck-and-neck, almost; it's plausible that if Cold Fusion had been free, it might have taken more mind share away from PHP.
Interpolating results into HTML dynamically isn't an idea that originated with any of this software. Prior art is the shell "here document", also implemented by imitation in Perl and other languages. "Here documents" were used in CGI scripting before PHP. (I'm not saying that the shell's "here document" is the ultimate prior art, either).
At your system prompt:
$ cat <<!
<table>
$(for x in 1 2 3; do echo " <tr><td>$x</td></tr>" ; done)
</table>
!
<table>
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
</table>I was talking to some kid who wanted to be a developer, and I echoed this sentiment. A complex tool with good documentation is easier to use than a simple tool with bad documentation.
What I dislike about it is the comments that every page includes. Most of them are very poorly written snippets of code from 15 years ago.
If you dislike those comments too, consider adding this to your ad blocker:
php.net###usernotesThere is the issue of bad advice, but recently I've noticed that there seems to have been a voting system introduced at some point (not sure how long that's been there, I was away from PHP for a good chunk of the last decade), and I think the moderation system is older, so in theory, some of the worst advice should be filtered down/out and some of the best should be filtered up.
I don't block user comments on PHP doc pages out of spite, I do it because they are very long, making it harder to scroll vertically on the actual documentation.
Its a minor quibble on desktop, but on mobile its a really annoying feature because I have to manually scroll with my finger for an age.
Yes, but then if I'm looking for a specific part it has scrolled way past and I need to then scroll back down, sometimes past it, and then scroll back up. Bearing in mind I have to scan the page as it flashes past too.
It's a frustrating experience.
It is also one of the few choices available on cheap shared hosting sites.
In a previous site of mine i had the entire site be statically generated but needed some server-side stuff in one of the pages, so i put something like %%PHPCODEHERE%% and modified the script that built the site to replace the %%PHPCODEHERE%% with the contents of a .php script.
PHP is the VBA of the web: it's ugly but too useful to ignore.
"serverless" now means you don't run your own web server, you use someone else's.
PHP is very much comparable to serverless. All that talk about bootstrapping costs in serverless is something PHP developers have been tackling forever.
I believe the post you're responding to was alluding to the degree to which a lot of single-file PHP/HTML is written in a very "serverless-esque" way: no dependencies on an outer framework, and likely scales quite far compared to other languages when run on any number of servers (with the required libraries).
The only reason I use php for my own sites is because I don't want to administer any server and I don't want to be tied to a provider.
PHP is a good fit for this, because it's available at practically all cheap hosting providers (I don't need to administer the server with shared hosting) and I'm not tied to a single provider, because I can switch to an other hosting provider without too much effort.
With other langauges I either have to manage my own VPS (I don't want to pay for managed VPS), or I'm tied to a provider (Appengine, etc.).
I just kept using Java, .NET and C++, while enjoying their performance, IDE tooling, and whatever ideas they could bring into their web stacks.
Nowadays most cool companies that were pushing Ruby, are on JVM languages.
I only got to know one start-up doing Ruby (not Rails), which happened to rewrite our Perl deployment scripts as a project subcontractor, as they didn't had anyone with Perl knowledge.
I think the staying power of php is at least in part due to the continued success of popular projects that rely on it, whoever was responsible for its initial successes.
A handful of projects really are the driving reason for PHP's ubiquity.
Wordpress/Joomla, phpBB/Invision/vBulletin, Magento...
The demand for support for these and some smaller and similar projects really drove webhosts to need to support PHP, and for a lot of the standardized tooling webhosts used, such as cPanel/WHM and Plesk, to support not only PHP, but the automated installation of these projects.
Sure, WordPress wasn't the first - phpNuke, Postnuke, etc, were really popular CMS tools before WP, but if we're talking staying power, you really can look at the stuff I listed as being why it has stuck around.
It's mostly that everything else was either worse (ASP), or insanely overengineered (JSP), or both (ColdFusion).
Also, with LAMP, you had a stack that was free top-to-bottom. Back then, it still wasn't as common as it is in the industry today, and that especially helped it in the hobbyist and small business niche.
When PHP gained full OOP support with PHP5 the Perl community was still tearing itself apart over introducing a MOP and which of the dozen Moose clones should reign supreme. That was the final nail in Perl's coffin, at least in it's bid to compete with PHP.
All other things being equal, security is usability[1] anti-pattern. You don't get to make clever hacks (in the original sense) on a secure system.
Unix was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. - Doug Gwyn
--
[1] at the very least for a power user or a developer
Another relevant quote: "I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say 'Yeah it works but you're leaking memory everywhere. Perhaps we should fix that.' I’ll just restart Apache every 10 requests."
And: "For all the folks getting excited about my quotes. Here is another - Yes, I am a terrible coder, but I am probably still better than you :) "
...which is probably true, but all the more reason to use tools that work properly rather than encouraging me to build more poorly thought-out stuff on top of a broken hack.
[1] https://en.wikipedia.org/wiki/PHP#cite_ref-itconversations_1...
I think PHP's strength was also its weakness: an amalgamation of specialized functions thrown into a global namespace without having to bother with modules, CPAN or anything.
If you're an experienced dev it looks like a huge mess but if you're a complete beginner it makes it easier to work with.
What do you mean?
The way I see it was PHP captured the vector of change, and left ample room for future developments. Both internal changes (hello, bytecode; hello, JIT), language level features (hi there, namespaces), and runtime level features (oh hai, countless built in classes and functions).
Moreover, unlike many framework that shone brightly and burned out quickly (Rails?), PHP captured the essence of the environment: HTTP is stateless, and URLs aren't uniformly routable from either end, and well-formed HTML/XML/JSON is just a subset of tag soup.
Worse is better.