PHP and Python are two of the most popular programming languages for web programming. While Ruby is also popular, it has taken a back seat recently to these two.
- Ubiquitous. It's available everywhere, even on some free web hosts.
- Performance. PHP is fast. Bottlenecks in a PHP-based web site typically come from the DB engine or server, not from PHP itself.
- Poor reputation. PHP has a reputation as a "beginner" language and isn't taken seriously by many programmers.
- Inconsistent library. Some of the standard PHP functions (substr/strpos!) have inconsistent naming or parameter ordering.
- Comprehensive standard library. The Python library is widely regarded as excellent and well-constructed.
- Clear syntax. Python is sometimes called "pseudocode that runs".
- Significant whitespace. Because whitespace determines Python code scope, changes that go visually unnoticed can cause difficult-to-debug errors in your project.
- Not ubiquitous. The lack of a standard Python web library means it's not usable except on VPS hosting. You can write Python CGI anywhere the interpreter is installed, but this is likely to result in poor web site performance. This isn't Python's fault, but because of how it's being run on these servers.
Python is a more general language than PHP (there are lots of command line scripts and desktop apps written in Python). PHP is specifically intended to be a web programming language and has features like query line parsing, database integration and templating that make developing web sites much simpler.
What are some other comparison points between these two very popular and useful programming languages?
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. As of January 2013, PHP was installed on more than 240 million websites (39% of those sampled) and
2.1 million web servers. Originally created by Rasmus Lerdorf in 1995, the reference implementation of PHP is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext
Preprocessor, a recursive backronym.
PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. It has also evolved to include a command-line interface capability and can be used in standalone graphical applications.
PHP is free software released under the PHP License. PHP can be deployed on most web servers and also as a standalone shell on almost every operating system and platform, free of charge.