In-depth explanation of the basic PHP syntax structure _ PHP Tutorial

Source: Internet
Author: User
In-depth explanation of the basic PHP syntax structure. The lexicalstructure is a set of basic rules for managing how to write programs in a language. The syntax structure is the lowest level of language syntax, and the variable name is specified.

The lexical structure is a set of basic rules for managing how to write programs in a language.

The syntax structure is the lowest level of language syntax, and defines what the variable name looks like, what characters are usually used for comments, and how to separate program statements.

PHP basic syntax structure 1. case sensitivity

Like built-in structures and keywords (such as echo, while, and class), user-defined class names and function names are case insensitive.

Therefore, the following three rows are equivalent:

Echo "hello, world ";

ECHO "hello, world ";

EcHo "hello, world ";

On the other hand, variables are differentiated by size. That is to say, $ name, $ NAME, and $ NaMe are three different variables.

PHP basic syntax Structure 2. semicolon

PHP separates simple statements with semicolons. Composite statements use braces to mark code blocks, such as conditional tests or loops. do not use semicolons after braces. Unlike other languages, the right parenthesis (?>) in PHP) The semicolon is not required.

PHP basic syntax structure 3. blank spaces and line breaks

Generally, blank spaces do not matter in PHP. You can expand a statement into any row or compress the statement into one row. This flexible format can be used to make the code more readable (by arrangement and distribution, indentation, etc ). Some lazy programmers do not advocate using this free format to create code that cannot be read at all.

PHP basic syntax structure 4. program Comments

For those who read the code, the comment is actually equivalent to the explanation and description of the code. Annotations can be used to explain the purpose of the script, the author of the script, why the code should be written in such a way, and the last modification time.

PHP supports C, C ++, and Shell script-style annotations, as shown below:

// Single line comment
/**/Multi-line comment (note: nesting is not allowed)
# Script annotation


Lexical structure refers to a set of basic rules for managing how to write programs in languages. The syntax structure is the lowest level of language syntax, and the variable name is specified...

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.