First I would say it depends on what you need from programming language. This question can be split into 2 questions: "Where Java is better than PHP?" and "Where PHP is better than Java?". So, let's start from the first one:
Java would be better choice than PHP in following scenarios:
1. You need multi-purpose language, not just for web app, but for android development, client development etc.
2. You need to created multi threaded application to use CPU as much as possible. Example would be multiplayer game server.
3. If you want to develop efficient automated programs like periodically generating reports, working on heavy services, image or video processing.
Some popular Java Frameworks are: Spring, Hibernate, Apache Kafka, Play.
PHP is better choice than Java if you have following requirements:
1. You want to learn quickly and start developing then PHP is much easier than Java, both learning and developing in PHP is faster than Java.
2. If your only goal is to make simple websites then PHP is a way to go: the most of simple websites built on Wordpress - which is a PHP project.
3. If you want to find small jobs as a freelancer, most of small businesses use PHP because it's widely adopted for simple websites and landing pages.
Some popular PHP frameworks are : Laravel, Codeigniter, Zend, Symphony, Yii 2, CakePHP
Major Technical differences between Java and PHP are: Java is compiled language, where PHP is interpreted language. Java has strict type checking, PHP doesn't have (you can assign Integer to String if you want). There are some other differences when it comes to compare technical details.