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

How to understand php variables and basic syntax

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

Share

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

How to understand php variables and basic syntax, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Basic syntax of php

Mixed compilation of 1.html and php

two。 A statement ends with; (semicolon)

3. How to determine a variable and the use of a variable

4. The data type of a variable is not fixed

5.php is a weak data type programming language

6.php is case sensitive

7. A valid variable name begins with a letter, number, and underscore, followed by any number of alphanumeric underscores.

Basic syntax enhancement of php

The data type of the variable of 1.php is variable and depends on the context, so it is a weakly typed language.

2.var_dump can view the data type of a variable

3. Define a variable that starts with a $symbol

4.php variables do not start with numbers and keywords, they can start with numbers and underscores

Three types of php data

1. Basic data type

1.1 × × ×

1.2 Decimal (floating number) includes single precision and double precision

1.3 Boolean types (true and false)

1.4 string

two。 Compound data type

2.1 Array array

2.2 object object

3. Special data type

3.1 null

3.2 Resource type (resource) for example: $con=mysql_connect ("localhost", "root", "root")

Details of the three types of php data

1. Integer values can be represented with decimal, hexadecimal 0x or octal 0

$a = 1234; / / Decimal number

$a =-123; / / negative number

$a = 0123; / / Octal number (equal to decimal 83)

$a = 0x1Abatten / hexadecimal number (equal to the zero power of decimal 26 = 10x 16 + the power of 1x 16)

2. Php does not support unsigned integers, that is, integers in php are signed.

3. The word length of the × × number is related to the platform, usually (4 bytes signed). The word length of the interger value can be expressed as the constant PHP_INT_SIZE, and the maximum value can be expressed as the constant PHP_INT_MAX.

Examples are as follows:

Echo PHP_INT_SIZE;-4

Echo PHP_INT_MAX;-2147483647 2 to the 31st power minus 1, the first bit is the symbol bit

4. If a given number is outside the range of interger, it will be interpreted as float

$large_number=2147483647

Var_dump ($large_number);-float

The way 5.$a=2 is stored in computer

00000000 00000000 00000000 00000010

Use the following example to parse the form of variables that exist in memory:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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