So why are people still learning PHP?
- a) It’s a really simple language to get started with
- b) If you’re doing web development (I question anyone using it for anything else, though it is possible) it is incredibly powerful
- c) There are some amazing libraries available, saving you a lot of time and effort
- d) The package manager (Composer) is one of the best that I’ve ever come across
- e) It’s incredibly well supported by various hosts, the security community and more
- f) PHP developer jobs pay really well, especially as there’s a shortage of good developers and a lot of vacancies (at least, that’s my experience)
- g) The documentation (primarily on ) is tremendous. Some of the best for any language I’ve ever worked with
- h) You can start learning it in your bedroom. You don’t need to fo to university to get a basic grounding in PHP
So why wouldn’t you use it?
Going back to point a, it’s a very simple language to get started with, but it takes a long time to master. It keeps you interested. At least it does if you’re working on interesting challenges.
People will make ridiculous statements about why PHP is bad. The two most common ones that I come across are:
1. Function arguments and names are inconsistent.
Sure, and that’s true. Weird things like
getclass(). Some functions take arguments in the order needle/array, others take array/needle.
How long does it actually take to get used to this? No idea, because I never really noticed that it was a problem until someone told me that others complain about it. Besides, my IDE fills all of this stuff in for me anyway, so it’s not like I even have to refer to the brilliant documentation.
This is the biggest non-issue I’ve ever come across and is literally people scraping the barrel when trying to bad mouth the language.
2. Variables have a $ prefix
Yes they do, and a lot of people complain about that. I like it. It makes it REALLY clear which are variables. There are also other conventions, such as constants being full caps, so it becomes trivial for anyone to read what something is.
$user = new User(User::TYPE_ADMIN);
A completely contrived example, but I’m quite clearly instantiating a new
Userobject, passing in a class constant that suggests that I want an admin user, and assigning it to the
$user variable. And then everywhere that I use
$user, it’ll be obvious that it’s a variable. No confusion about whether it’s a constant or not, you know immediately that it’s a variable.
If this is an issue for you, you have to take a step back and look at yourself and consider whether you really are the reasonable person that you think that you are.
So, PHP is perfect, right? No, of course it isn’t. You can’t use it for the front-end, and you really didn’t ought to be doing much outside of the web with it – that’s literally what it was originally designed for. There are also some TERRIBLE tutorials out there, including advising to use MD5 and SHA1 to store user passwords at rest.