Java guarantees the upward accounting of the language, in practice it is possible to update the JVM without any problem, it is almost impossible to have an application problem after this update.
In PHP, however, major version updates can cause problems in the application, this problem is accentuated by the fact that PHP is not a compiled language (unlike java), so that a problem arises it is absolutely necessary that the code in question is executed by the visitor of the site. We must therefore perform user test numbers at each version update.
Java uses a "packaging" mechanism, that is, the web application is packaged into a zip file (with the .war extension) while PHP simply deploys the files to the server. The java approach is better for important updates in a business process because it ensures that all files come from the same version and its compatible with each other. On the contrary PHP makes more complicated the global update with that for the simpler update and the minor corrections they can be done directly on the file in the web application.
Best choices: JAVA (except any small project)