Comparison of PHP with JavaScript

Source: Internet
Author: User
PHP and JavaScript are also dynamic languages, but there are many differences between them. Compare here.

JavaScript PHP The The A semicolon at the end of the The The
variable names can start with a $ or letter variable names must begin with $
variable definition is typically used with the var keyword variable definition without var
string is the same as the single quotation mark and the double quote effect strings are not escaped with single quotes, and are escaped with double quotes
logical operators only && and | | This form logical operators have && and | | And and and or two forms, and the two form priorities are different
statement can omit the semicolon at the end of the statement, not omit the
string supports Unicode strings that do not support Unicode
connection string is used with the + sign connection string. #
You can use global variables directly inside a function to use global variables inside a function must first be declared with the Global keyword
Gets the nth character of a string with Str.charat (n) to get the nth character of a string with Str[i]
ordered index with array, unordered index with object ordered index and unordered index can be used array
concatenate all elements of an array use the Join function to concatenate all elements of an array with the Implode function

Resources:
[1] ECMAScript Standard
[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.