I know some Java programmers consider PHP to be a simple language for simple solutions. But the number of PHP powered sites is really large. PHP powered content management systems (CMS) have great look and exciting features. When you write in plain PHP without using any of the PHP frameworks, it sucks. It really does. You have to split the page in a few ‘tiles’, then include this pages in every page, to have the same header and footer for example. You also do not have a ‘cross-application’ context, so you cannot use in-memory cache as much as we do it in Java applications.
I also like the idea of tags in Java. Do not know whether it is a Java invention or not. Tags are great and can be of great help and a great time and money save for many projects. In order to have something like tags in PHP you have to write a function that will print the html in an old servlet style. It sucks. I also do not understand why there is no database connection caching in PHP. I asked my friend, a professional PHP programmer if this is a good practice to make a connection to the database and then close it. He said YES and why not. However, maybe there is a cache that is just hidden from the programmer? If so, this is great.
The big thing I do not like in Java is that the JVM and the server such as Tomcat are the real memory hogs. That is why the hosting is expensive and they require to have experienced staff on board to tune and maintain such hosting. I know GoDaddy (my current hosting) claims to support Java in their cheap hosting plans (starting from 6 bucks a month). I think it can be good for a very simple application. I also know they do not let file I/O operations. It is not very good. Therefore, Java is wrong for simple and hobbyist projects. My blog is a PHP powered Wordpress system. I would love to install a Java-based solution, such as blojsom (a wicked name, isn’t it?) but I have no desire to pay 30 bucks a month for the cheapest VPS plan to install Java-based stuff. However, PHP rocks for that niche.
They say PHP was made by web designers and for web designers. I have no doubt in that. Check out PHP projects - they are all beautiful, tons of themes and templates. Java projects are made by software engineers who do not really care if their work looks beautiful or not (think of pre-ocean Java Swing look and feel).
I also get used to easy debugging of Java projects, to logs (thanks Log4J), to an exception handling mechanism. PHP is great and the quantity and high quality of PHP software is amazing. PHP is good for any solution, Java is good for any solution if you can afford to pay high hosting bills.