Objectively speaking, I'm quite confident in saying that Python is superior in every conceivable way, but I'm sure you will find people who will disagree. If you are starting from scratch, I really don't know why a person would choose PHP.
Most of the benchmarks I've seen show Python to be significantly faster than PHP.
Okay people seem to be clamoring for how I came to my objective soapbox, so I will repeat what I said in the comments below:
Python provides more language features for making a developer's life easier. For example, it allows for easy functional programming constructs such as lambda functions. It also provides for multiple inheritance. As well you can change the inheritance hierarchy of an object after the object has been instantiated. Further, you can give function parameters names and use those names in the callers to make your code more readable and avoid the ugly PHP requirement of passing in a bunch of default variables to a method just to set the nth parameter to some non-default value.
Python, in many benchmarks is faster. It has a more robust memory management system and garbage collector. PHP has no garbage collector, it uses reference counting to determine which memory to free. This can result in memory leaks in long running programs with significant class and object dependencies/hierarchies.
Arguably, Python has a larger and more sophisticated base of applications, frameworks, and plugins. For example, SQLAlchemy is an extremely powerful ORM and Database Abstraction Layer. There really isn't anything equivalent in PHP.
Python is an older language. One could argue that its age means that it's had more time to mature and get better.
I'm sure there are other reasons as well, and I'm also sure that you can write pretty much whatever you need in PHP as well as in Python. But looking at what each language provides, IMHO, shows Python to be better.
And one more edit before I head out: Late static binding was added to PHP in 5.3 but it's still sort of half-assed (http://www.digitalsandwich.com/archives/65-Late-static-binding....sorta.html). That's another feature that exists in other languages like Python but just seems to be lacking something in PHP.
Okay, I just have to see this through because I am amazed at the response that has come up from my claim that python is better.
There seems to be a recurring theme amongst some software developers that every language, practice, and method is always covered by a YMMV-type belief. But it seems to me that this can sometimes masquerade an unwillingness to take a stand at best and naive relativism at worst.
The question asks which is better for web services development, python or PHP. I made the claim that it is objectively true that python is better than PHP for this task and I stand by that claim. I even go so far as to claim that python is general better than PHP.
Some people believe that it's an unfair statement, that somehow it's not possible for one to be objectively better than the other. I strongly disagree and I definitely believe that one language can be shown to be better than another both for a specific use and in general terms. Indeed, this must be so otherwise the phrase "use the right tool for the job" would be meaningless; i.e., if there is a right tool then there must by definition be a wrong tool.
Python is, in general terms, more "right" as a software development language, including and especially for a FastCGI-based web service, for several reasons which I have tried to make clear. These include, but are not limited to:
- More robust memory management and far better garbage collection, especially for long running processes, which if FastCGI is used, the process will indeed be long running. PHP is notorious for leaking memory. Obviously it has gotten better in this regard lately but it is still a significant risk for someone running an FCGI PHP process.
- Better and more seamless Unicode and multibyte character support. PHP is notoriously horrible in this regard. None of the built-in PHP string functions are multibyte safe and even a simple str_replace() can mangle your multibyte strings. Yes, I know that you can use mb_string_* replacement functions but it is still a weakness and not every built-in function has an mb_string replacement (str_replace is a case in point).
- Python has far more support for both Object Oriented Programming and Functional programming. Python's OOP features far surpass PHP's, including as mentioned dynamic and flexible inheritance hierarchies and late static binding. While not every developer will use these features, the fact that they are in the language and robust gives you more options and more flexibility. Python's functional programming constructs are also missing from PHP.
- Python has several third-party libraries that are second-to-none. Django, SQLAlchemy, and Albatross are just a few libraries that are highly regarded in the development community. SQLAlchemy especially provides features that don't exist elsewhere, or are more cumbersome, even in the big corporate languages like C# and Java. The OP wants to build a web service layer-- I'm not sure there's anything in the PHP world that would compare with the elegance and flexibility of Albatross + SQLAlchemy. That is a significantly powerful combination that I would wholeheartedly recommend to anyone wanting to build any significant web services infrastructure.
- Python has other syntactic sugar that gives it more flexibility and power than PHP. I mentioned at least one of these features earlier, named parameters, that I miss often in PHP.
The base criteria that I have suggested include language features, runtime robustness, and available third-party libraries. Note that in order for python to be better than PHP, it does not require PHP to be considered completely awful that no person in their right mind would ever use (though I do personally wonder why someone would build a green-field project in it), but when you are asked to make a comparison by the question and you have to determine criteria by which to make that comparison I don't see how you can argue with the claim that language features, runtime robustness, and third-party libraries are a bad criteria.
Objectively, Python has more language features than PHP for both OOP and functional programming. That should not be contentious--- you can make a list and count the bullet points.
Objectively, the python runtime is more robust. It has more sophisticated memory management, and PHP is known to still to this day have memory leaks that can make long-running processes exit with an out of memory error.
I suppose you could take me up on the third-party library claim, but if you do know of anything in PHP that compares to either Albatross or SQLAlchemy for the poster's desires, PLEASE for the love of god let me know what it is because I need to start using it right away in my own PHP projects.