You “can” but is it the best solution? Other languages exist that were built as functional from the ground up. PHP also tends to run slow compared to other languages. It’s yet another reason I choose to avoid the language.
As for javascript it’s a popular language so many people have built on top of it making more and more new things that rely on it, at its core though it’s an still an old language people are constantly making major changes to it so I see it still having a long life though I have my concerns, I guess javascript is worth learning due to the vast amount of open source projects written in it and the many UI Libraries like React and Vue which require it.
I don’t see much value in learning PHP unless you want a job maintaining older codebases which rely on it. I’d rather not spend the rest of my life maintaining a PHP codebase, it would be a very dull life to me.
EDIT: I’ll add the javascript version made around 22 years ago, isn’t the same javascript we have today. I don’t know which variants of javascript to consider relevant to today’s work vs which variants of javascript are legacy. I’m conflicted as to which types of javascript are relevant.