Can you please elaborate ?
Also, I hear Facebook uses a lot of PHP. So, what kind of stuff I will be able to do with Java and not PHP and viceversa ?
There are two things . you can do everything in java what you can do in PHP.
That is being said . It all depends on the performance and scalability of the application if you are thinking in a long -term.
Yes Facebook uses a lot of PHP and they have developed couple of frameworks on their own for their needs.
I will explain you with an example.
You want a Online shopping portal site . you dont know how you want and what type of features you want. you dont care about what programming language you need that application to be coded.
So here choosing the language will depend on me (developer)
And i will think like
1.Customer with no predefined requirements which means he may need or dont need some features when the site is being developed.
this should come under agile methodology of development.
2.I need to think of a language that i need the application to be coded in . So i have a lot of options . since you ask about Java and PHP . ill compare the two situations .
a. Java & PHP both can be used to Develop the application so there is a stalemate
b. PHP is much more flexible and suitable for web application than Java so PHP wins here.
c. Both Java and PHP can be scaled (adding new features) but adding in php is much more easier. PHP wins
There are a lot more considerations if you take in database and servers .
P.S I a web application developer , Android Developer so have experience in both PHP and Java frameworks.
other professionals may agree or disagree . But the thing that counts is what the developer feels comfortable while building the application