An in-depth explanation of PHP basic grammatical structure _php tutorial

Source: Internet
Author: User

The syntax structure of a programming language (lexical structure) is a collection of basic rules that govern how to write programs in a language.

The syntax structure is the lowest-level language syntax, and it's what the variable names look like, what characters are commonly used as annotations, and how to separate program statements.

PHP basic Syntax Structure 1, case

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

Therefore, the following three lines are equivalent:

echo "Hello,world";

ECHO "Hello,world";

EcHo "Hello, World";

On the other hand, variables are size-sensitive. This means that $name, $NAME, and $name are three different variables.

PHP basic Syntax structure 2, semicolon

PHP uses semicolons to separate simple statements. Compound statements use curly braces to mark blocks of code, such as conditional tests or loops, and do not use semicolons after curly braces. Unlike other languages, a semicolon before the closing parenthesis (?>) in PHP is not required.

PHP basic Syntax Structure 3, whitespace, and line breaks

In general, whitespace characters do not matter in PHP. You can expand a statement to any row, or tighten the statement to a single line. You can use this flexible format to make your code more readable (by arranging allocations, indenting, and so on). It is not recommended that some lazy programmers use this free format to create code that cannot be read at all.

PHP basic Syntax Structure 4, program annotations

For the person reading the code, the comment is actually the equivalent of the code's explanation and description. Annotations can be used to explain the purpose of the script, the script writer, why to write code in such a way, the time of the last modification, and so on.

PHP supports C, C + + and Shell script style annotations, as follows:

Single-line Comment
/* */Multiline Comment (Note: cannot be nested)
# Script Comments


http://www.bkjia.com/PHPjc/446008.html www.bkjia.com true http://www.bkjia.com/PHPjc/446008.html techarticle The syntax structure of a programming language (lexical structure) is a collection of basic rules that govern how to write programs in a language. The syntax structure is the lowest-level language syntax, and the variable name is set ...

  • Related Article

    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.