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...