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

Example Analysis of Syntax, constant, variable and data Type in PHP5.4

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

Share

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

This article mainly introduces the PHP5.4 syntax, constants, variables, data types of example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.

First, the basic grammar and writing format of php5.4.

1. PHP is mixed with HTML tag language.

Example:

This is an example.

2. The delimiter of PHP statement

3. Php comments and syntax identifiers

1. / / A double slash pattern (order number comment) comes from the annotation mode of C++ grammar.

2. # pound sign annotation mode (order number annotation) comes from the annotation mode of C language

3. / * and * / slashes with asterisks (multiline comments) are derived from UNIX's shell language schema.

3. The format of the function

1. Return the value function name ()

2. Return the name of the value function (parameters, parameters … )

3. Function name (parameters, parameters, etc. , returns a variable)

4. Return the name of the value function (… .) caller

Second, variables and variable data types of php5.4.

1. The variable name begins with a dollar character $, followed by an identifier. Identifiers consist of letters, numbers, or underscores. The identifier of a variable name cannot start with a number and the variable name is case sensitive.

2. Description: when multiple words are combined into a variable, there are several schemes.

1. Direct connection between words. $titlekeyword

2. Connect the words with an underscore. $title_keyword

3. Capitalize the first letters between words. $TitleKeyword

3. Variables and variable data types

1. String (string) single quotation mark (simple quotation mark) or double quotation mark (function quotation mark)

2. Integer (integer)

3. Floating point (float or double)

4. Boolean true or false

5. Array array

6. Object object

7. Resource type (Resource) system data resources

Third, system constants and custom variables of php5.4.

1. Constants are data that cannot be changed during program execution, and the scope of constants is global. Constants are named like variables, except without the dollar sign $. Generally speaking, constants in php are capital letters and are divided into system constants and custom constants.

2. Example of system constant:

1. The default constant of _ _ FILe__ refers to the file name and path of the php program.

2. The default constant of _ _ LINE__ refers to the number of lines of the PHP program.

3. The name of the _ _ CLASS__ class.

3. In PHP, a constant is defined through the define () function, and its syntax format is:

Bool define (string $name,mixed $value [, bool case_$insensitive])

Name: specifies the name of the constant.

Value: specifies the value of the constant.

Insensitive: determines whether constant names are case-sensitive. If set to true, it is case-insensitive, if set to false, it is case-sensitive, and if this parameter is not set, the value defaults to false.

1. Define ("COLOR", "red"); / / define a constant COLOR with a value of red.

2. Echo COLOR. "

"; / / output the value of COLOR

Thank you for reading this article carefully. I hope the article "sample Analysis of Grammar, constants, variables and data types in PHP5.4" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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