In-depth interpretation of the basic syntax structure of PHP_PHP tutorial

WBOY
Release: 2016-07-15 13:34:17
Original
1018 people have browsed it

The lexical structure of a programming language refers to the set of basic rules that govern how to write programs in the language.

The syntax structure is the lowest level of language syntax and specifies what variable names look like, what characters are commonly used for comments, how to separate program statements, etc.

PHP basic syntax structure 1. Upper and lower case

Same as built-in structures and keywords (such as echo, while, class, etc.), user-defined class names and functions Names are not case sensitive.

Therefore, the following three lines are equivalent:

echo "hello, world";

ECHO "hello, world";

EcHo " hello, world”;

Variables, on the other hand, are size-sensitive. That is to say, $name, $NAME and $NaMe are three different variables.

PHP basic syntax structure 2. Semicolon

PHP uses semicolons to separate simple statements. Use braces to mark blocks of code for compound statements, such as conditional tests or loops. Do not use a semicolon after the braces. Unlike other languages, the semicolon before the right bracket (?>) is not required in PHP.

Basic syntax structure of PHP 3. Whitespace and newline characters

Generally speaking, whitespace characters do not matter in PHP. You can expand a statement to any line, or compact the statement to a single line. You can take advantage of this flexible format to make your code more readable (by arranging allocations, indentation, etc.). Some lazy programmers take advantage of this free format to create code that is simply unreadable, and this is not recommended.

Basic syntax structure of PHP 4. Program comments

For people who read the code, comments are actually equivalent to explanations and explanations of the code. Comments can be used to explain what the script does, who wrote it, why the code was written the way it was written, when it was last modified, etc.

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

// Single-line comments
/* */ Multi-line comments (note: cannot be nested)
# Script comments


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446008.htmlTechArticleThe lexical structure of a programming language refers to a collection of basic rules that govern how to write programs in a language. The syntactic structure is the lowest level of language syntax and formulates variable names...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!