PHP has been designed primarily as a web language. It’s fairly simple to get it up and running – good news for new web developers. The language, however, is often described as limited and programming concepts beyond syntax are usually left to other languages.
PHP is often thought of as not so much a language, but more as a wrapper around other languages with memory management and a more flexible type system. There are many inconsistencies in PHP (e.g., in function names) and is of the “structure is optional” philosophy, this requires more discipline for programmers to code well. In a nutshell PHP is a language that encompasses all useful things in all other languages. Which, I guess, makes it inferior.
What is Python?
Python, OTOH, is a general-purpose language that is gaining popularity fast as a web language. It has greater applicability, but it’s a little more involved when it comes to getting it up and running on a web server. Python is certainly the more flexible of the two languages. It’s an ideal language for a new programmer, but not maybe not so ideal for a new web developer. However, if you already have experience developing web apps, this is probably not an issue.
What’s good about Python?
- It is very expressive (little code does a lot)
- The code is simple to read
- If you are already an experienced programmer it will only take a few hours to get into the swing of it
- Nice clean code
- Real and consistent object system
- Better documentation than PHP (though PHP is not bad)
- More consistent libraries
- BDFL (PHP is a mess!)
- Good C API
- Excellent web frameworks
- Excellent desktop app support
- Very cross platform compatible
Great Python features
- list comprehensions
- functions as first are first class objects (you can pass functions around just like any other piece of data)
- functional programming tools
- indentation determines scope (though this annoys some), which makes the code look nice
- slice notation
- powerful native data structures (lists, dictionaries, sets)
- args and *kwargs
- awesome standard library
What is good about PHP?
- Easy to deploy on a webserver
- Easy to integrate with HTML (good for small sites)
- If you already know some PHP it may be easier to build your PHP framework if you want to build your app fast.
Some programmers complain that PHP does not support Functional idioms, brain dead functions, and name spaces. Though there are many work abounds that extends its functionality.
You can read more about these on PHP.net:
It’s possible to write good PHP code but you have to exercise some discipline for it not to get messy.
Python Programming or PHP programming conclusion
Sometimes you don’t have time to configure the server to run a specialised application, you need something that can be installed and used right away in the shortest amount of time. Choosing PHP may be more of a business decision if time is of the essence. So it may come down to figuring out whether it would save time now and later to use PHP or Python.