It isn’t correct to compare Java to PHP. Since PHP is a server-side scripting language whereas Java is a general-purpose language. In other words, PHP is only used as a server-side language where Java is both for server-side and desktop programming language. Moreover, Java is compiled and strongly-typed language. On other hand, PHP is a dynamic typed language. Hence, only for server-side programming, the comparison between Java and PHP makes sense.

In this paper, I am not discussing following two issues since each is currently hotly debated in various communities:
• Strongly typed languages vs. dynamic Languages or Scripting
• Ajax vs. Smart Clients

Programmers
- There are millions of bad programmers: Both Java and PHP programmers.
- Everybody is a PHP programmer. Even monkeys! Almost all web hosting companies use Apache Server/PHP.
- Changing or creating a page in PHP is easy. Creating a page: Use Drupal, WordPress, Xoops, Php-Nuke etc
- For JSP (Java) it is also easy to change or create a page. However, for a complex application, monkeys cannot do programming in Java.

Language features & libraries
- Java is OO. So is PHP now (PHP 5.0).
- Java Provides reflection (reverse-engineer classes, interfaces, functions). PHP is finally added the same feature in PHP 5.0. Note: Reflection enable you to architecture your application better.
- Java has a richer set of API.
- Java provides management API (JMX) for managing and monitoring devices and applications.
- There thousands of OSS projects for Java (apache.org). Java provides a clean mechanism to combine these libraries (jar) to compose a complex application.
- Java provides native transaction mechanism.
- Java has a persistence mechanism to convert Java objects to database table entries and table entries to Java objects.
- Java has annotations: Annotations can be used for both compile-time and run-time.
- Java has thread support: Executing tasks in parallel.
- There are many other languages that can run within Java or on JVM (Ruby, Groovy, Python, JavaFX etc)

Download pdf PHP vs. Java