Talk about a few of the different and identical Java and PHP I know

Source: Internet
Author: User

Java language and PHP language because both can do Web application development, so there is always a beginner to learn these 2 languages The beginner will ask Java and the PHP which one is good. Discussion of the quality of the language is not a very wise thing, I think only to say that a programming language more suitable for doing, the biggest difference between humans and animals is that people will use tools, and the appropriate tools to do the right thing will be more effective, the contrary will be less effective, like overkill, Cannon hit mosquitoes, It sounds like a very good tool, in fact, in killing chickens and playing mosquitoes in the two things sledgehammer, Cannon really is not as good as a chopper and electric mosquito racket.

Application faces are different:

Although Java is currently used primarily as an enterprise application programming, and the use of BS ( Browser-to-server ) architecture, but it can be said to be more all-round, desktop applications, embedded, mobile, server can be used Programming in the Java language.

PHP is focused on dynamic web technologies.

Different language types:

Java is a strongly typed compilation language, and the most notable feature of strongly typed languages is that variables must be declared and assigned before they are used, and undeclared variables cannot be used. Compiled languages are very efficient in execution because they are compiled by the compiler.

PHP is a weakly typed interpretation language whose variables are not declared data types and can be used directly without assignment. Interpretation languages do not need to be compiled, so they are less efficient to execute than compiled languages.

There are different syntax operators:

PHP has the "= = =" symbol, meaning to check the left and right sides of the type and value is equal, and Java does not have this symbol, and its role is equal to equals method, this method is a method in the top-level parent class object of all classes in Java , and to use this method must overwrite it in a subclass that uses the method, Otherwise it acts on the "= =" symbol.

In a looping statement, PHP has a foreach statement specifically for iterating over the array, but there is no such statement in Java , but there is an enhanced for , and its function is basically the same as foreach .

Object-oriented support differs:

Java is a fully object-oriented language that requires programmers to program objects.

Although PHP also supports object-oriented, it does not force the use of object-oriented Web page architecture, which makes php more free in web programming.

Different output modes:

Java has only 2 ways of output, one is System.out.print () and System.out.println () statement to print the information to the console, which is printed without wrapping, and the latter is printed and wrapped. The other is to get the output stream through the API to output the information to a file, another computer, or a Web page.

PHP output information will be output on the Web page, and there are a variety of output statements. such as echo,vardump,print and so on.

Have a better cross-platform nature:

Although the Java language is a compiled language, it does not compile the source code into machine code on a particular platform, but rather compiles it into a Java bytecode file, which is then made up of a JVM on a particular platform (Java Virtual machine ) , although it is less efficient than direct compilation to machine code execution, this scheme successfully achieves a balance between cross-platform and execution efficiency, and this gap is almost negligible as the current level of hardware continues to improve.

PHP is interpreted as a language, it runs by explaining the engine to explain the run, and the interpretation engine can be used across platforms. But because it has not been compiled, it needs to be interpreted once every execution, and all execution efficiency is worse than Java .

Summarize:

These two languages in the production of Dynamic Web pages, the cost ofPHP production is lower, more suitable for information and personal dynamic website building.

Java Because of its security, multi-threading, synchronization mechanism, cross-platform execution efficiency is more suitable for data security and capital flow, and other aspects of the site building, so the use of Java is a number of large and medium-sized companies of enterprise-level development.

Talk about a few of the different and identical Java and PHP I know

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.