At work I have written a couple of CGI scripts in Perl, because that was the easiest, fastest way to get a working solution to a relatively small problem. I know CGI is totally '90s, and Perl has not been hip for at least a decade, but damn it, it gets the job done quickly without fuss.
I kind of suspect that with PHP the situation is comparable to Perl - you have a well-tuned, mature interpreter, a rich library ecosystem for almost any task you can think of, and a community of experienced developers.
PHP isn't perfect at all, with all its inconsistencies and counterintuitive constructs, but it works great. Lots of libraries you can install with Composer, most people know at least some PHP.
On top of that, unless WordPress isn't rewritten in a new language (which won't happen) PHP won't go anywhere.
Perl is fine, too. We solve problems for clients who pay us to get the job done, not be brag about how we use the latest, coolest technology.