What is the difference between Java and Php?

PHP and Java are both very similar when it comes to the benefits provided, but they are both very differences between Java and Php. PHP is a server-side scripting language, while Java is a client-side choice.

When you use PHP code, you will execute it in the actual server, while Java will be executed on your client’s computer. This means, if you use Java and the client doesn’t have the right program, such as Java Runtime Environment, your webpage won’t show up. With PHP, this isn’t an issue.

 JAVAPHP
The Java Class library provides a mechanism to implement threads.PHP has no such mechanism.
In Java, a separate method must be defined for each possible list of parameters.PHP methods and functions allow for optional parameters.
Java does not.PHP requires an explicit $this be used when an object calls its own methods.
Java programs tend to be built from a “program runs, stays running, processes requests” kind of way.PHP applications are built from a “run, handle the request, stop running” kind of way.
Java is compiled to bytecode.PHP is interpreted.
Java is strong and statically typed.PHP is rather weakly and dynamically typed.
Java can do that too, as well as Applets, mobile phone software, Enterprise stuff, a desktop application with and without GUI, 3d games, Google Web Toolkit, etc.PHP is mostly used to dynamically generate Web pages.
In, Java, OOP is the default.PHP offers OOP (object-oriented programming) as an option that is ignored in most projects.
All Java String constants use double quotes and have no such variable evaluation.String constants in PHP are declared using single or double quotes. Double quotes will evaluate variables embedded in the text.
Java uses the . operatorPHP object method calls use the -> operator.
Constructors in Java are named after the class name.In PHP they are called __construct()
Method overriding and overloading is quite natural in Javabut a bit of a kludge in PHP

Leave a Reply