Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic grammar knowledge of PHP

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the basic grammatical knowledge of PHP". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the basic grammar knowledge of PHP"?

Escape to PHP

The PHP parsing engine needs a way to distinguish PHP code from other elements in the page. The mechanism for doing so is called "escaping to PHP". There are four ways to do this-

Canonical PHP tag

The most common and effective PHP tag style is-

If you use this style, you can be sure that your label will always be interpreted correctly.

Short (SGML style) label

Short or short labels look like this-

As expected, a short tag is the shortest option. You must do one of two things for PHP to recognize the tag-

Select the-- enable-short-tags configuration option when building the PHP.

Set the short_open_tag setting in the php.ini file to open. This option must be disabled to parse XML using PHP because the XML tag uses the same syntax.

ASP style label

ASP-style tags mimic the tags that Active Server Pages uses to describe code blocks. The ASP-style tag looks like this-

To use ASP-style tags, you need to set configuration options in the php.ini file.

HTML script label

The HTML script tag looks like this-

... PHP code comments

One suggestion is that it exists only in the human reader and part of the program that was stripped off before displaying the results of the program. There are two comment formats in PHP-

Single-line comments-they are usually used for short descriptions or comments related to native code. The following is an example of a single-line comment.

Multiline printing-the following is an example of printing multiple lines in a single print statement-

Multiline comments-they are often used to provide pseudo-code algorithms and more detailed explanations when necessary. The style of multiline comments is the same as C. The following is an example of a multiline comment.

PHP is blank insensitive.

The space bar is what you type and is usually not visible on the screen, including spaces, tabs, and carriage returns (end-of-line characters).

PHP whitespace insensitivity means that it hardly affects how many white space characters you have on a line. A white space character is the same as many such characters.

For example, each of the following PHP statements that assign the sum of 2 + 2 to the variable $4 is equivalent-

$four = 2 + 2; / / single spaces$four =

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report