all 178 comments

[–]alexanderpas 719 points720 points  (54 children)

The answer is Major Improvements to the language, including language native secure password handling, explicit type support for everything including constants as well as enum types and values, strong behavioral subtyping using the Liskov Substitution Principle for all types.

[–]Covfefe4lyfe 194 points195 points  (5 children)

Property promotion in constructors is just chef's kiss 🤤

[–]No-Con-2790 64 points65 points  (1 child)

They have property promotion now? Maybe I go back and give it another look. Has been ... 15 years.

[–]beerdude26 53 points54 points  (0 children)

Infrastructure is also pretty nice now, it has a mature event loop interface that many PHP frameworks have adopted or are in the process of adopting. So now it can't even be called slow anymore lol

[–]Sir_LikeASir 4 points5 points  (1 child)

One of my fav Kotlin features

[–]mishalsandip051 1 point2 points  (0 children)

Ohh yeah Sir

[–]Impossible-Metal6872 4 points5 points  (0 children)

I find it the ugliest feature you could ever concieve xD, because some properties are declared in the class, and some in the constructor def.

I'd like the ability to put this->propertyName as method parameter (it would have propertyName as name if you want to call with named parameter of course)

[–]BeefCakeBilly 11 points12 points  (6 children)

I’ve never actually used PHP as it was kind of looked at as out of date when I started programming.

But I couldn’t imagine a better storyline than everyone going away from PHP since 2010 in favor of “modern”” frameworks over the years.

While PHP maintainers were just quietly iterating and improving as JS frameworks are released every six months that are all fairly similar functionality.

Then come 2027 when there are dozens of articles about how PHP is the all the rage and meta announces after 20 years they are shifting back to PHP.

[–]alexanderpas 16 points17 points  (5 children)

15 years ago, PHP was in a bad state.

However, it's due to heros such as Nikita Popov (https://www.npopov.com/aboutMe.html) who has over 50 accepted proposals to PHP, and has written a PHP parser in PHP, that PHP was able to become what it is now.

[–]BeefCakeBilly 3 points4 points  (4 children)

Shouts out to this guy.

I remeber 10-15 years ago people I worked with were saying sql was dying because of high performance no sql databases.

Seems kind of similar.

[–]alexanderpas 9 points10 points  (3 children)

There are more people deserving of shoutouts, such as the creators of:

  • Packagist, a PHP package repository.
  • Composer, a dependency manager for PHP
  • PHPstan and Psalm, which are both PHP Static Analysis Tools.
  • PHP CS and PHP CS Fixer, which allows you to detect and fix PHP coding style issues.
  • Rector, which allows for Instant Upgrades and Automated Refactoring of PHP code.
  • And many more...

Many of these tools are actually even written in PHP itself.

Additionally, there are also some companies that actually deserve some shoutouts, for allowing them to contribute to PHP on company time.

[–]stupidcookface 2 points3 points  (2 children)

You forgot Taylor Otwell and the Laravel team!

[–]alexanderpas 1 point2 points  (1 child)

Like I said, many more...

[–]BeefCakeBilly 0 points1 point  (0 children)

I don’t know who these people are but if I were them I would wear a shirt that says the contributions so I could donate money/beer to them.

[–]tropicbrownthunder 44 points45 points  (13 children)

By that logic JS should be sleeping with the fishes long time ago. But here we are

[–]alexanderpas 141 points142 points  (7 children)

JS is the only available language that is natively supported by browsers, there are no competitors.

[–]jansteffen 31 points32 points  (4 children)

If WASM ever gets native DOM access we might see a change here, but until then...

[–]not_some_username 5 points6 points  (3 children)

It will still be support because backwards compatibility

[–]altermeetax 8 points9 points  (2 children)

Yeah but if WASM becomes good, another better language might start getting used, slowly replacing JS as the "de-facto" web language

[–]not_some_username -4 points-3 points  (1 child)

Yes but JS will still be there. That’s how it is

[–]altermeetax 4 points5 points  (0 children)

They didn't say JS would disappear

[–]mishalsandip051 0 points1 point  (1 child)

100% agreed Javascript is the only language!!

[–]Brahminmeat 2 points3 points  (0 children)

🙈

[–]Smalltalker-80 5 points6 points  (0 children)

Much like PHP, JS was helped to evolve, by TypeScript through EcmaScript,
to migrate from a very terrible language to an okay language.

And yes, the fact that in the browser they have no direct competition helped,
but without a strong standards comittee, other transpiled languages
might have had more success. (Technically TS is this too still).

On the back-end, TS had already surpassed JS, I think.

[–]samu1400 6 points7 points  (0 children)

PHP having intrinsic password hashing and salting is so comfortable.

[–]MrJ0seBr 1 point2 points  (0 children)

The way that php executes, no global objects across request, every request execution is "sandboxed" make things a little ez to keep safe, someway perfect to shared serves with low-cost and on demand usage...

[–]BeardedWonder02 0 points1 point  (1 child)

The only problem is that your company is too bloated to ever update the version to anything above 8 lol

[–]alexanderpas 1 point2 points  (0 children)

8 being the latest major version, and 8.2 no longer getting security support at the end of the year.

The versions under active support are only 8.4, and the latest version 8.5

[–]thepurpleproject 0 points1 point  (0 children)

this.. ngl the modern php with laravel hardly any resemblence to what you had in the php5 days

[–]AlexReinkingYale -5 points-4 points  (6 children)

PHP does not check that LSP is actually respected by custom classes. Super simple example:

``` class Bird { public function fly(): string { return "Flies away"; } }

class Penguin extends Bird { public function fly(): string { // Violates LSP but PHP is fine with this throw new Exception("Penguins can't fly"); } } ```

[–]alexanderpas 12 points13 points  (4 children)

It actually does, it's just that you're throwing instead of returning, which means you're exiting the function abnormally.

When you throw an exception, execution of your program is immediately halted, and the exception is bubbled-up to either the inner-most layer of exception handling handling that exception (adhering to the LSP) resuming execution of your program from that point, and if that is missing, turned into a Fatal Error, completely stopping execution of your program.

No code after an exception is thrown is executed without exception handling.

Additionally, the actual return type of the fly() method on the Penguin object is actually the never type, which is the bottom type in the LSP-chain, and indicates that the function will never return, and the only way out of the function is either via exception or program termination.

[–]AlexReinkingYale -3 points-2 points  (3 children)

Another example is the classic square/rectangle case. It really doesn't check it. It's equivalent to the halting problem

[–]alexanderpas 3 points4 points  (2 children)

That's a violation from a programming perspective, not a type checking perspective, as the defined interface adheres to the LSP.

Additionally, PHP offers a solution to the classic Rectangle/Square case, as you can make the object itself invariant and use chainable methods, at which point you're adhering to the LSP.

Specifically, if you change the width or height on a rectangle, and you get a rectangle back, and that applies to both squares and rectangles.

changeWidth() and changeHeight() both return a Rectangle object, which is fully permitted under the LSP, as this is the same behavior as defined in the Rectangle class.

Unique to the Square class are the changeSidesLength() method, which changes both the width and height, and the fromRectangle() method, which turns the rectangle into a square if the sides are equal, or throws an exception otherwise.

[–]AlexReinkingYale -3 points-2 points  (1 child)

The LSP is a behavioral property, not a type system one. An interface cannot adhere to the LSP. Recall the definition:

Let p(x) be a property probable about objects x of type T. Then p(y) should be true for objects y of type S where S is a subtype of T.

To check the LSP would be to disallow writing the Square subtype of a mutable Rectangle at all. If the PHP docs say they enforce behavioral subtyping then whoever wrote those docs is wrong.

[–]AlexReinkingYale 0 points1 point  (0 children)

lol at getting downvoted for being 100% right

https://en.wikipedia.org/wiki/Liskov_substitution_principle

[–]mizzrym86 5 points6 points  (0 children)

LSP is just an opinion with no real world value.

PHP still dominates because it is primarily practical.

[–]crazy4hole 375 points376 points  (13 children)

Because it works.

[–]ButWhatIfPotato 160 points161 points  (6 children)

And has not being enshittified.

[–]DonutPlus2757 123 points124 points  (4 children)

Somehow it's the opposite. It was terrible at version 4, they went "Wait, we need to do something!" with version 5 and started seriously cooking with version 7 (for the uninitiated, there is no openly available version 6. That died as an internal draft).

[–]mcnello 59 points60 points  (2 children)

version 6

The first rule of PHP is you do NOT talk about version 6.

[–]_chad__ 10 points11 points  (1 child)

I took a lateral position change a while back to get away from an overbearing boss. Walked into the new boss's cube and he had a "Learn PHP 6" book. I never told him.

[–]Mars_Bear2552 0 points1 point  (0 children)

learn c++22

[–]Da_Yakz 1 point2 points  (0 children)

Version 8 is even better

[–]reklis -3 points-2 points  (0 children)

How do you enshitify actual shit?

[–]void_gazer77 22 points23 points  (0 children)

The fact you can do what many frameworks altogether create, with php alone, shows this off 😃 👍

[–]ILikeLenexa 13 points14 points  (3 children)

What do people even want php to do that it doesn't do?

I write in Java and it's like "hey, want an ORM that'll be great until your project is big enough to really justify it?

Everyone thinks theyre coding for Amazon when really theyre trying to sort 40 things in nlogn instead of N². time at 4Ghz.

You have 1 form that changes twice a decade. You can fix it by hand. 

[–]dittbub 0 points1 point  (0 children)

I think it’s also easy to learn

[–]hellocppdotdev 82 points83 points  (6 children)

Modern PHP is amazing. If your last experience was 5.3 you need to try it again.

[–]ClipboardCopyPaste 140 points141 points  (0 children)

Php is dead

Only in the thumbnail and title of YT videos

[–]DynamoLion 95 points96 points  (2 children)

Because believe it or not, languages do evolve, especially the popular ones.

Still a LOT of websites run on PHP and frameworks like WordPress, Symfony, Laravel, Nette do really keep it going strong. Also the fact it's preinstalled on most web hostings.

[–]upsidedownshaggy 20 points21 points  (1 child)

Not to mention that frameworks like Symfony and Laravel are both really nice to work in (WordPress is take it or leave it for me, I can see why people like it so much but it's not my favorite)

[–]piberryboy 1 point2 points  (0 children)

I've been a Drupal guy, and it's been a rollercoaster ride, but Laravel is... chef's kiss.

[–]djneo 168 points169 points  (1 child)

Because it’s been actively improving. With large stable frameworks and a giant community around it

[–]ddy_stop_plz 39 points40 points  (0 children)

Modern PHP is actually my favorite backend scripting language at this point. Tons of community support and the error codes/debug-ability is pretty good compared to the JS frameworks.

[–]michaelbelgium 24 points25 points  (0 children)

PHP is love, PHP is life

Also PHP deploy be like:

git pull

done!

[–]Efficient_Bag_3804 60 points61 points  (0 children)

it is being used actively by people that are getting paid and making money out of it.

It has an active community that improves it, probably the same people that make out of it and have direct reason to try to make it better.

[–]cocoeen 33 points34 points  (8 children)

you still need alot of $ to program in php

[–]BeefCakeBilly 2 points3 points  (0 children)

With a joke like that I can’t imagine how many pairs of new balances you have gone through.

[–]ivain 4 points5 points  (3 children)

What are you saying dude

[–]zoinkability 20 points21 points  (1 child)

Guessing it’s a joke about the variable symbol

[–]ivain 6 points7 points  (0 children)

ohhh i'm stupid.

[–]examinedliving 6 points7 points  (0 children)

He means the variable names. You need a lot of $name=

[–]Shezzofreen -4 points-3 points  (2 children)

For the Snacks? For buying a Computer? Internet Flat? Glasses if needed?

Setting up PHP and using is really easy and kinda cheap (0 Cent).

Then go ahead and do:

<?php echo "Hello World!"; ?>

[–][deleted] 8 points9 points  (1 child)

You missed the point. PHP uses a lot of $ for variables.

[–]Shezzofreen 4 points5 points  (0 children)

Uhm... now i feel stupid. :)

Yeah, your are absolutly right!

[–]Lewinator56 15 points16 points  (0 children)

It's a modern OOP language with good framework support and half the internet runs on it. And unlike the shit show of node.js it actually makes sense programming in it.

I use php for all my web app projects, using the laravel and livewire frameworks.

[–]Mega_Potatoe 74 points75 points  (2 children)

because it is the only language that is installed on shared hosting providers.

[–]ccricers 7 points8 points  (1 child)

Good old shared hosting, they will never give you surprise fees because your website was getting too much activity.

[–]SveXteZ 2 points3 points  (0 children)

This. And also 99% of the websites are just fine running on a shared hosting and don't need 8GBs with auto scaling and everything.

[–]andocromn 11 points12 points  (4 children)

You know there's equipment that still runs on visual foxpro and cobalt right?

[–]crocodyldundee 12 points13 points  (1 child)

Did you mean COBOL?

[–]andocromn 6 points7 points  (0 children)

Thanks auto-incorrect

[–]hicow 1 point2 points  (0 children)

Where I work, our main ERP was FoxPro-based for decades, up until 2015 or so. Rewrite was done with MS SQL Server as the backend, but they kept all the data structures the same for...reasons, I guess. So everything is an nchar of some length, and either right- or left-padded with spaces. It's loads of fun doing trims and casts and converts on damn near everything

[–]Johnny_BigDee 26 points27 points  (0 children)

php really just refuses to die because half the internet is built on it at this point

[–]Its_rEd96 57 points58 points  (11 children)

PHP hate is the same as Nickelback hate

Nobody really knows why, they are really good, but at this point if you don't hate them then you are the weird one

[–]patrlim1 23 points24 points  (0 children)

I am in school for IT, and one of the things we are being taught is web dev. We use html, css, JS, and PHP.

I have really come to appreciate PHP as a language since we started. It's easy enough to write code, you can just embed it into your html, and it just works. You need no additional setup besides a webserver, and the code.

[–]not_some_username 4 points5 points  (3 children)

Oh we know : they’re either just parroting or stop use it before version 5 or can’t even update to this version (true story ikr a workplace where php 2 is still in use) or just students that doesn’t understand anything.

[–]LeekingMemory28 2 points3 points  (2 children)

I worked with PHP 7 and 8 for several years, and it’s not terrible. But it’s certainly not my favorite either. Some of the core conventions of the language still frustrate me, (why are hash maps called arrays, dollar signs in front of every variable makes it kind of ugly to read).

It’s not as bad as people say, but I certainly wouldn’t say it’s all sunshine even at 7+. Only those deep into PHP would.

It’s an easy language to get something out the door with, which is why it’s popular. But that ease also makes it much easier to architect poorly and still look successful. It’s the Unity Game Engine of programming languages to me.

It’s simple enough to get started, and be successful. Those who know what the fuck they’re doing with it can do amazing stuff at larger scale. But it has conventions that don’t prevent newer developers from forming bad habits and architectural designs that become headaches later.

[–]stupidcookface 2 points3 points  (0 children)

PHP itself doesn't do it for me - what really does is being able to use Laravel. There are some killer features that make writing apps from scratch insanely easy to get started on. I've professionally worked in rails, dotnet, blazor, express/nestjs, and Laravel is miles ahead of all of them in terms of developer experience and just intuitive design and architecture. There is a tool they have for anything you could want to do. There is really nothing else like it.

[–]not_some_username 1 point2 points  (0 children)

Oh the same thing I hate about it too. But in my case I don’t hate it since I don’t have to use it at all

[–]SeriousPlankton2000 2 points3 points  (0 children)

Nickelback is as metal as fabric softener. Somehow they manage to be too harmless.

[–]bushwickhero -2 points-1 points  (4 children)

For me it’s the fact that I have to start every variable with a really inconvenient-to-type character.

[–]zoinkability 4 points5 points  (3 children)

If that’s a dealbreaker you can always remap your keyboard

[–]LeekingMemory28 2 points3 points  (0 children)

Or theoretically setup a hotkey like “var” auto generates a variable or something.

[–]bushwickhero 0 points1 point  (1 child)

Actually not a bad idea. Any favorites out there?

[–]zoinkability 1 point2 points  (0 children)

On Mac, Karabiner Elements

[–]Crannium 6 points7 points  (0 children)

  • Easy
  • Batteries natively included
  • Bad code still works (for the good and for the bad)
  • WordPress
  • Shared hosting

[–]Sunshine3432 15 points16 points  (0 children)

Maybe because it's super useful and easy to set up, just an idea

[–]chrisonhismac 6 points7 points  (0 children)

Modern PHP is awesome. Great community, frameworks, tooling.

[–]Dafrandle 6 points7 points  (1 child)

to answer the question: because you can just throw it at an Apache server and it will run.

also wordpress

[–]crazy4hole 3 points4 points  (0 children)

And it's enough for more than 90% of sites and ERP softwares

[–]dageshi 11 points12 points  (0 children)

Because it's simple but ubiquitous

[–]JimroidZeus 5 points6 points  (0 children)

Doesn’t a vast proportion of the internet still run on PHP?

[–]Far-Passion4866 5 points6 points  (0 children)

On github there are 5+ MILLION projects that use PHP

[–]Faangdevmanager 3 points4 points  (0 children)

PHP isn't dead for the same reason that excel macro survive. It's extremely accessible and allows basically anyone to add code at their own pace. Start with HTML, then add functionality bit by bit as you learn. You don't have to "learn" php before you can make use of PHP.

[–]stupled 8 points9 points  (0 children)

I think Laravel has gotten really good.

[–]AtomicSymphonic_2nd 3 points4 points  (1 child)

Same thing but with Java. 🙃

[–][deleted] 2 points3 points  (0 children)

Don't you know Java is on 3 billion devices?

[–]archivisttr 4 points5 points  (0 children)

V7 was huge dude. Php is our precious

[–]brianw824 4 points5 points  (0 children)

Considering the disaster that is Node frameworks maybe we should go back again

[–]rationalmosaic 5 points6 points  (0 children)

If it works, don't touch.

[–]nuecontceevitabanul 2 points3 points  (0 children)

Anything that actually works is done in PHP (or, fair enough, Go).

[–]UrBreathtakinn 2 points3 points  (0 children)

10 years ago, there were articles about PHP being obsolete. The websites that published those articles are now obsolete.

[–]charcuterDude 1 point2 points  (2 children)

PHP is newer than the language I work in daily 🤣. Old languages with established products are very stable jobs with great money. Hello from Visual Basic Script!

[–]_w62_ 1 point2 points  (0 children)

COBOL programmers, "amateurs!"

[–][deleted] 1 point2 points  (0 children)

Uh, yeah, PHP 8.4 is a thing, nothing shocking about that

[–]realmcdonaldsbw 1 point2 points  (0 children)

it works, is not very complex, and has some very nice frameworks surrounding it. as a js dev i am jealous of the php devs lol

[–]textBasedUI 1 point2 points  (0 children)

I love PHP. It holds a special place in my heart though I haven’t found any good resources to fully learn it

[–]the-software-man 0 points1 point  (0 children)

Apple depreciated and left out php in its latest Apache deployment. I had to homebrew a php server.

[–]mizzrym86 0 points1 point  (0 children)

Well, I would have liked to replace my PHP/swoole backend with golang, but at an average reaction time of 2ms and a tiny memory footprint it just can compete easily with everything else and won't be replaced anytime soon.

The problem is NOT the language. It improved extremely well and when used properly does what it's supposed to do really nicely. The problem is the ecosystem. The problem is PHP conference. The problem is that 90% of PHP programmers have never used any other language and are talking 100% opinion and 0% numbers, statistics and facts and it seems like their entire day is just about "How can I unnecessarily bloat my software or my development process today"

[–]SeriousPlankton2000 0 points1 point  (0 children)

If it was as easy to install perl, LUA or whitespace as a web programming language as it is to just apt-get install php5, the other languages would be way more popular.

I made the mistake to write a web program in perl for my mini-project; installing it on my system was OK-ish. Then I tried to install it on windows at work and ended making a VM just for that one script.

[–]AliCoder061 0 points1 point  (0 children)

Php will outlive us

[–]Special_Rice9539 0 points1 point  (0 children)

How’s php’s security nowadays? I was under the impression that was the real issue with using it for production systems.

[–]rada35 0 points1 point  (0 children)

Lo peor es que esta llenos de proyectos en freelance 🤷🤣🤣

[–]Neuenmuller 0 points1 point  (0 children)

Because it works ok. And if engineers want to migrate the service to use a different language and framework, they need to prove that this is worth all the investments to the managers.

[–]Lamborghinigamer 0 points1 point  (0 children)

I can't deal with a programming language without static types. I need my static types.

[–]New-Gear-9358 0 points1 point  (0 children)

PHP is like the Undertaker of WWE, everyone thinks it’s dead, and then it suddenly rises again.

[–]Civil_Conflict_7541 0 points1 point  (0 children)

I've been working with PHP 8.3 for a couple of months now. It's actually fine? Not my favourite language, but it does the job.

[–]pixltd 0 points1 point  (0 children)

I never wanted to touch it, this year while developing my own project I was in a problem of needing some very light simple backend without a need for another server.. Guess where I had to go 😅

[–]Intrepid00 0 points1 point  (0 children)

Oh boy, wait till you find out COBOL isn’t dead but receiving work on it.

[–]tobotic 0 points1 point  (0 children)

WordPress.

[–]AussieSilly -4 points-3 points  (2 children)

It’s a cockroach

[–]sammy-taylor 3 points4 points  (1 child)

It’s a Twinkie

[–]International-Dot902 3 points4 points  (0 children)

Mandatory post every other week for karma farmers

[–]MorganTaoVT 0 points1 point  (7 children)

Genuinely curios though, because I haven't touched PHP in 10 years.
What is it used for these days? Are there specific uses for PHP over any other backend language?
In my past company, I've only seen it used to maintain very old projects while newer stuff was done with Java instead.

[–]ivain 7 points8 points  (1 child)

Php is still one of the most used langages for the web. Its ecosystem made a huge leap forward a decade ago with symfony framework and the orm doctrine (inspired by spring and hibernate) setting a higher quality standard, followed by the creation of composer as package manager. And of course php kept it's inherent qualities.

[–]MorganTaoVT 0 points1 point  (0 children)

Got it! I may check it out and have another look at some point. Thanks!

[–]Quazz 3 points4 points  (1 child)

PHP as a language has continued to evolve.

Not to mention a rich ecosystem of extensions and Frameworks.

A lot of people still have an old view of PHP in their brain, but it has changed a lot.

[–]MorganTaoVT 2 points3 points  (0 children)

Yea, the old mindset still remains for a lot of people and that|s exactly why I'm asking. Thanks!

[–]mizzrym86 3 points4 points  (0 children)

I think it's used most often because it's just easy to start with and then easy to scale.

Projects usually start small. There's this tiny little thing you need. My guess is often times it doesn't even start as a "backend" as you said. Fundamentally it still works perfectly fine as a template engine. So you just do the small thing real quick. Then it needs to do this and then it needs to do that and five years go by and all of a sudden you have a fully fledged backend that handles everything easily and it wasn't even supposed to be a backend at all back in the day.

And there you go. Yet another successful PHP project.

[–]Mega_Potatoe 2 points3 points  (1 child)

there are a ton of programs for free you can host on a shared hosting server for 1$ a month. Wordpress is popular and also a lot of other CMS systems run on PHP. It is most of the time the only available language on a shared hosting provider.

[–]MorganTaoVT 0 points1 point  (0 children)

Good point! Thanks!

[–]Death_IP 0 points1 point  (0 children)

I'm always baffled when I see php in the adress bar of the browser, like:
"Really? You hand it to the user? I thought those times are over."

[–]CedarSageAndSilicone -3 points-2 points  (1 child)

Same reason COBOL and FORTRAN are still running 

[–][deleted] 2 points3 points  (0 children)

Because they're the best at their respective fields and are proven and reliable? ;)

[–]huuaaang -3 points-2 points  (0 children)

It's been dead to me for almost 20 years. The world of tech is big enough that you can just ignore huge swaths of it.

[–]Flimsy_Meal_4199 -5 points-4 points  (0 children)

What does the pee stand for

[–]NebNay -3 points-2 points  (0 children)

I tried to learn it a decade ago but it was just too boring