views:

1368

answers:

11
+1  Q: 

PHP or Python?

How to go about to get started learning php. Which one is best to learn php programming or python. I just want to know which one of these is leading.

+5  A: 

If you go by the TIOBE index:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

PHP has a pretty good lead on Python. However, I wouldn't use this as a measure. You should learn both, I would say. As far as what's becoming trendy, Python is definitely on the rise, there's no doubt about that.

BobbyShaftoe
Why the downvotes? I was going by the question that was asked. Is it because I didn't say you should worship at the feet of all things holy regarding PHP or Python?
BobbyShaftoe
+8  A: 

PHP probably has a lower barrier to entry in that it's embedded in what are essentially HTML documents. Python is a more full-blown general-purpose programming language. If you just want to throw some Web pages together, it's hard to beat the simplicity of PHP.

PHP is by far more common although with Django, Python is becoming increasingly common for Web development.

cletus
could you give an example of Python being used for Web development? i'm curious about this.
Devoted
@koldfyre: Django is the most obvious example of that.
cletus
@koldfyre: Django, turbo gears, zope, divmod etc
Dan
+5  A: 

You can learn Python quickly reading Dive Into Python online.

too much php
+2  A: 

In addition to which language, you might want to ask yourself which framework are you interested in using? I think learning a framework can take more effort than learning the syntax and idioms of a language. Do you plan on learning either PHP or Python for web development?

barneytron
+6  A: 

I think you ask the wrong questions...

Which one is best to learn php programming or phython.

The concept of "best" applied to language is nebulous and misleading...

I just want to know which one of these is leading.

I don't see how it is important. I mean, neither are going to die next year, so it is quite irrelevant. You will find plenty of information, help, books for both languages.

For Web development, I think PHP is leading, partly because lot of hosts offer PHP out of the box, and more rarely Python, Perl or Java. And partly because of tradition. If the question is for job offers, you will probably find more offers if you know PHP.

That doesn't mean that Python is unsuited to Web development, of course. Somehow, you should have a superficial look at both languages, at some frameworks they offer, and choose along your taste.
And nothing prevent you to learn both, at least after mastering at least one of them...

PhiLho
+1  A: 

Python might be a good language to learn, since easier to read (makes it mandatory to indent the code).

kal
+2  A: 

Disclaimer: I use PHP to earn my bread and butter, so I may be more readily critical of that language than Python.

PHP is more popular, but popular is not a measure of good taste; a glance at the Top 40 album charts should confirm this :)

I think the most significant difference between these languages is that Python design was clearly led by one person, whereas PHP has grown more organically. This means that there are more apparent inconsistencies in PHP than in Python, and these can lead to "uglier" code.

Like any language, both have developed design flaws or inconsistencies over time. In my observation Python moves more agressively to address these than PHP does.

One of Python's orginal design goals - at least a major focus of it's aims today - is as an educational tool. So by focussing on Python initially, you may make yourself a better programmer for future tasks in other languages. I would be reluctant to say the same of what PHP might teach you.

My advice is to try both to achieve a few simple tasks, and see which makes sense to you more intuitively. Also, dig into a few of your favourite existing pieces of software (assuming you aren't an "everything from scratch" type) and see which make more sense.

That should make the decision clear enough.

Best of luck - hope you enjoy your learning experiences!

Chris Burgess
"apparent inconsistencies" is an understatement :-D
Dan
I heartily agree, Dan; my choice of words was intended to steer towards a more NPOV. PHPs lack of consistency is deeply frustrating for me.
Chris Burgess
A: 

I suppose it depends on whether or not your code is going to be run on a lot of web servers. PHP, due to high demand, is usually available on most shared hosting servers, and thus is the choice of projects such as Wordpress and Drupal. I've also found that most of those shared hosting web servers have a pretty ancient version of Python.

While I haven't done a lot of web stuff in it, I feel that Python is the better language in general, and may even replace PHP (assuming software inertia doesn't keep PHP going).

Rishabh Mishra
+1  A: 

Another thing to consider: are you only ever going to be programming web sites?

PHP isn't commonly used in other domains; Python is.

Tim Lesher
A: 

In terms of which language is leading overall, the answer is clearly PHP. This is true not only in the number of sites which currently use PHP, but also in the number of PHP resources out there compared to Python.

This is by no means a knock against Python, which as stated before can be a very useful language to use for educational/learning purposes.

TheTXI
A: 

Python has a nice syntax and it is far more better than PHP!