I'm probably older than you. My beard is grey. My experience is long. I've had the chance to witness many coding trends over the last 20+ years. I've seen languages come into vogue (looking at you, Ruby), and I've seen some of those same languages become vilified (looking at you, ColdFusion). So it's been kinda curious to me to see how PHP is currently treated in the marketplace (and has been treated for quite some time).
I started throwing up web pages in 1995 (yeah... I'm that old). My first website was hosted on Geocities (yeah... I'm that old). By 1998, I was frustrated by the limitations of the "static" web and I was already looking for other solutions. Wayyyy back then, your options for creating a truly-dynamic website were extremely limited. In fact, when I first got into this game, I had only two options: Perl or PHP.
To be clear, I have a lot of respect for Perl. It's a fine language. And, in some respects, it stills fills a valid niche on the "modern" web. But back in the 90s, Perl could be extremely problematic. Because back in the 90s, hosting providers hadn't yet figured out how to properly deploy containerized, virtualized environments. (In fact, the first hosting company that I used in 1998 was one of the first hosting companies on the web to offer virtual hosts).
Back in these "bad ol' days", most of the shared-hosting providers gave you only two options:
You could create a completely-static site by uploading your completely-static HTML files into their shared-hosting environment.
Or you could create dynamic code, driven by Perl, that would be executed in the
cgi-bin... but, before your code could be deployed, you had to pay the hosting provider an hourly fee to review your code before they would allow it be uploaded to your
cgi-binfolder. (This onerous - and expensive - restriction was completely understandable. Because they didn't have the virtualization tools to properly "wall off" your site from the others in the shared host. So if you wrote some really crappy code, you could destroy not just your own site, but every other site in the shared-host's directory.)
So... with the help of virtualization, PHP became possibly the first programming language that was readily offered to the masses to create dynamic web pages. Because once virtualization gained a solid foothold, a lotta folks who were signing up for their first virtual hosting environment found that the "server" came preinstalled with PHP (and the embryonic beginnings of MySQL).
Now I understand that if we're to adhere strictly to literal timelines, Perl preceded PHP - by a good bit. But I would stridently argue that PHP was the first "truly-internet" language that fostered widespread adoption of dynamic HTML. To put it another way: The first "script kiddies" didn't cut their teeth on Perl. They got their feet wet in PHP.
So I dove in. Somehow... I made it work. I wrote a crap-ton of thoroughly-embarrassing code. But somehow, some way, I managed to make it all "work" at the time.
Even the largest PHP fan will probably admit that its resilience is, in large part, attributable to WordPress. The WordPress team chose PHP - and, in turn, that fortuitous decision solidified a permanent place for PHP in web-development lore. Whether any of the "real" programmers wanna admit it or not.
We've all seen the web statistics to back it up. At any given time, there's an insanely-disproportionate number of public sites that are running on PHP. Of course, those "in the know" understand that those statistics are massively skewed by the bloggers and other amateurs' sites which are, technically, running on PHP (because the sites are built in WordPress) - even if the sites' webmasters (yeah... remember that term?) couldn't write a line of PHP to save their life.
Given my (long, greybeard) history, you can probably guess that I too have "evolved" beyond PHP. I moved to ColdFusion/MS-SQL, then to Java/Oracle, then to ASP/C#/MS-SQL, then to jQuery/Knockout/Angular/React. Like most people who are in the "long game" of app-dev, I've managed to get my grimy fingers into a stunning array of technologies - even if I'm still struggling to master any of them.
But I never really quit PHP. It's been installed on my local machines for decades. I've rarely ever been paid to write PHP - because, let's face it, most of the PHP jobs out there just don't pay. (Do I want to be your WordPress Administrator for $50k/year?? Umm... no.) But it's been an invaluable tool for those (many) times when I want to write some quick coding utility at home. Even as I've moved ever deeper into frontend development, I find myself often reaching for PHP because it's a quick-and-easy way to spin up a backend API.
Even though I still write some PHP in my spare time, I've known for a loooong time that being a PHP dev is usually best kept as a type of "dirty little secret". You can do PHP, but you should only do it when you're at home. Alone. With all the blinds closed. And for godsake, no matter what you do, never tell anyone that you actually write (and - egads! - enjoy) PHP. It's like the fetish porn of software development. There are plenty of people out there doing it, but if you wanna be accepted and respected by the "real" developers out there, you'd best keep that shit to yourself.
This point was driven home to me recently during two incidents when I was involved in a job search.
I was interviewing for a React position and I was doing a screensharing coding test with two of the company's senior devs observing my actions. When they gave me the instructions, I launched my IDE - JetBrains' PHPStorm. One of their devs immediately exclaimed, "PHP Storm???" He sounded like I'd just proposed scrawling the answers to their coding test directly on my monitors - in feces.
His exclamation was quite silly. I wasn't going to write any of the answers to their coding test in PHP. I wasn't going to run any of my completed code in PHP. I was only using an IDE that had "PHP" in the name. And this was enough to give this guy the creeps. (If you're wondering: I pay for the full JetBrains suite and I actually could have opened Web storm, which presumably woulda made this guy much happier. But I didn't have Webstorm configured locally and when you're in an interview, you don't have much time.)
They did not offer me a job.
I was completing a coding assignment with all kindsa hairy requirements - far more than you would normally find in a coding assignment of "acceptable" length. Nevertheless, I did the entire assignment. It had a React frontend, with authentication, and drag-n-drop, and GraphQL, and session management, and... a whole buncha crap that was wayyyyy more than any reasonable employer should ever ask for a coding assessment. But I did it anyway. I met every requirement.
Some time after I submitted the code, I learned that they didn't like my submission because I built the backend API... in PHP. Their requirements never said which tools should be used to build the API. They didn't say that I must use any particular tech stack. They didn't say that I couldn't use PHP. They just said that I had to include a GraphQL API. And I did that... in PHP. I did it in PHP because it was the fastest, easiest way to spin up an API with my local tools. I did it in PHP because I had already sunk a huge amount of time into the frontend functionality and I just needed a backend that worked. Nevertheless... they didn't like the fact that I'd used PHP to build the backend of this silly demo app.
They did not offer me a job.
Not that any of this really shocks me much. I've already known, for many years, that when I'm talking to other senior software engineers - in "real" jobs - that even mentioning PHP is a liability. You can be having a great conversation with a bunch of serious coders. And you can all be getting along fabulously. But if you let "PHP" escape from your lips, everyone gives you that awkward look like you just dropped an off-color joke on the group.
If this sounds like some whiny defense of the language, believe me, it's not. I've been around PHP long enough to sorta regard it as my kid. My ugly overweight kid who never did much in school, has been working dead-end jobs for years, and has had numerous run-ins with the law. You still love your kid. You still hope for nothing but the best for your kid. But after a certain time, even the most devout parent's gotta see when their kid has some... problems.
The 3.x versions of PHP were too experimental to critique. And most coders today have never actually seen a 3.x installation of PHP.
The 4.x versions were, in retrospect, a disaster. Much of the language's scorn arises from the 4.x versions. Magic globals, crappy database constructs, conflicting libraries, inconsistent syntax. All the warts were right there in the open for anyone to see.
The 5.x versions did, incrementally, improve the language. Granted, the road through the 5.x versions was far too long, and PHP's Release Candidate community seemed to bog down for quite a while. But they did, eventually, get through that wilderness.
The 7.x versions are... pretty damn good. There. I said it. You can laugh at me if you want. Have they fixed every potential headache in the language?? Of course not. But what language doesn't have at least some quirks that drive its developers nuts? But overall, I really kinda... enjoy writing backend functionality in PHP 7.x.
Of course, many of the knocks against PHP don't come directly from the language itself. They come from the community that's associated with its use. Specifically, many of PHP's haters have been jaded by the droves of hobbyists and dabblers that come along with WordPress. WordPress itself can be a Coding Beast From Hell. And then when you add in all the weekend warriors who are mucking it up because they're just trying to put up a basic site for their kid's soccer league? Well... you can run into some really amateur stuff. Stuff that gets indiscriminately painted with the broad brush of PHP.
So it's quite rich, nowadays, to see the blatant snobbery with which many JS devs heap scorn upon PHP. They obviously have no sense of coding history - or irony. Quite frankly, I don't think they care. The JS community has, over the last decade, become increasingly elitist, and this can really be highlighted when you observe their overall attitude toward PHP. Few of the JS devs I've met fully grasp the incongruity at play when the JS community tries to treat PHP like it's somehow "lesser", while acting as though JS is somehow "greater".
So what's the "answer" for PHP devs? Sadly, I don't know if there is much of one. Trying to shift the attitudes of many thousands of JS/Java/C#/Python/etc devs is probably impossible. Any chance to radically improve the language's "social standing" probably passed a long time ago. Not that I'm telling you to abandon PHP. It's a great tool (for certain jobs). There's nothing "wrong" with having that tool in your tool belt. But... you might want to make sure that it's tucked deep into a pocket where no one else is likely to catch you with it.