I. Classification of data types (three major classes eight small classes) 1. Scalar data types
- INT linear integer, can have decimal, octal, hexadecimal
<? PHP // decimal $v 1=255; Echo $v 1; // 255 //Eight binary------starts with 0 (the output is automatically converted to a 10-binary integer) $v 2=076; Echo $v 2; // 16 binary-----starts with 0x (the output is automatically converted to a 10-binary integer) $v 3=0xff; Echo $v 3; // 255?>
- Float with the number of decimal points, can be defined by ordinary methods, you can also use scientific notation, remember that decimals can not be arbitrarily compared between the size
<? PHP // defining floating Types $v 1=3.33; Echo $v 1; // 3.33 //Scientific counting method $v 2=1.22e+9; Echo $v 2; // 1220000000?>
<? If(0.7-0.3==0.4) { echo ' yes ';} Else { echo ' no '// output is no, indicating that it is not possible to compare the size of two decimal points?>
- Boolean two digits ture or false, set up or not set up
- String strings are 0 or more characters enclosed in single or double quotation marks
① a string defined using single quotation marks
Characters that can be escaped have \ \ (backslash) \ ' (single quote)
A variable of a string defined by single quotation marks cannot resolve its value
<? $num=10// single quotation mark defined string $strA= ' act\\ions spe\ ' ak Louder than Words $num 'echo$strA; // act\ions SPE ' ak Louder than Words$num?>
② a string defined using double quotation marks
Characters that can be escaped have \ ' (double quotation marks) \ t (tab) \ r (carriage return) \ n (line break) \ \ (backslash) \$ ($ character)
The value of a variable in a string defined by double quotation marks can be resolved
<? $num=10// double quotation mark defined string $strB= "Act\\ions spe\" AK lou\ $der than Words$num"echo$strB; // act\ions SPE "AK lou$der than WORDS10?>
③heredoc defines a string that defines a large segment of text
2. Composite data types
- Array arrays, divided into indexed arrays (subscripts are indexes) and associative arrays (subscripts are strings)
3. Special data types
- Null has only one value null
- The resource resource data type is a special variable that the programmer has no way of directly defining a resource and must use PHP to provide a function to get the resource
Ii. Conversion of data types
Data Types for PHP