Comparison between PHP and JavaScript

Source: Internet
Author: User
Comparing PHP and JavaScript, PHP and JavaScript are also dynamic languages, but there are still many differences between them. Here is a comparison.

JavaScript PHP
The variable name can start with $ or a letter. The variable name must start with $.
Variable definitions generally use the var keyword. Variable definition does not require var
The effect of a string using single quotes and double quotes is the same. The string is not escaped with single quotes and double quotes.
Logical operators are in the format of & | Logical operators include & | And Or, And they have different priorities.
The semicolon at the end of the statement can be omitted. The semicolon at the end of the statement cannot be omitted.
Unicode supported for strings Unicode is not supported for strings.
+ Is used to connect the string. Concatenate a string with a. number.
You can directly use global variables in a function. To use global variables in a function, you must first declare them with the global keyword.
Returns the nth character of a string using str. charAt (n) Use str [I] to obtain the nth character of a string.
Arrays for ordered indexing and objects for unordered indexing Arrays can be used for both ordered and unordered indexes.
Join all elements of the array using the join function Use the implode function to connect all elements of the array.

References:
[1] ECMAScript standards
[2] PHP official manual

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.