Data type Partitioning
1. Scalar type: int float string bool
2. Composite type: Array Object
3. Special type: null resource
Integer type: (int integer)
Three kinds of binary notation:
1. Decimal: 123
2. Eight binary: 0123
3.16 Binary: 0x123
Binary conversion: decimal to Binary decbin (), except 2 to write backwards
The English words in the system
Dec: Decimal
Bin: Binary
Oct: Octal
Hex: Hex
PHP conversion function: Decbin (decimal to 2 binary) (other conversions, etc.)
Note: decimal to other binary results is a string, and the other binary to decimal requires the given data to be in string form
Float type: Float document Real
String Type: String
Single quote: The contents of the output quotation marks are not escaped
Double quotation marks: outputs the contents of the quotation marks and escapes (interprets the contents of the quotation marks)
Boolean type: BOOL Boolean
Type of array: array
Definition $v1=array (1,2,3,4);
Type: Object
Resource type: Resource basically refers to a reference to external data. (data not generated by PHP code)
Null value type: null
Common functions related to data types
Var_dump (): The ability to output the full information of a variable
GetType (): Gets the type name of a variable, and the result is a string
SetType (): Sets the type of a variable setType (variable name, target type)
Isset () Determine if a variable has data
Empty () to determine if a data is null
unset (): Delete a variable
Operator:
Null decrement is invalid, increment result is 1
String merge operation: use.
Three-mesh operators:
Data 1? Data 2: Data 3
Bitwise operators: Bitwise operators are all based on the binary numeric form of integers
Bitwise AND Operation basic rules (rule table):
1 & 1 ==> 1
1 & 0 ==> 0
0 & 1 ==> 0
0 & 0 ==> 0;
3, bitwise or arithmetic basic rule
1 | 1 ==> 1;
1 | 0 ==> 1;
0 | 1 ==> 1
0 | 0 ==> 0
4, bitwise non-operation:
~ 1 ==> 0
~ 0 ==> 1
5, Bitwise XOR OR operation:
1 ^ 1 ==> 0
0 ^ 0 ==> 0
1 ^ 0 ==> 1
0 ^ 1 ==> 1
Rule: The same is 0, the difference is 1
Bitwise left-shift Operation:<<
a << n;//a is a number to be moved, the same can be a normal number, but by binary to operate, n is a specified to move
Bitwise RIGHT SHIFT operation:>>
a >> n;//a is a number to be moved, the same can be a normal number, but by binary to operate, n is a specified to move
Original code anti-code complement
Original code: is "The original binary code"
Inverse code: The inverse of a positive number is its own.
Complement: A positive complement is its own.
Array operators
Note: In PHP, the order of the elements of an array is not determined by the subscript (key name), but by the order in which they are added.
Union (+): Merges the right-hand array items behind the left array to get a new array. If there is a duplicate key, the result will be the left
Cases:
$v 1 = Array (1, 2, 3, 4);
$v 2 = array (5,6,7,8,9);
$r 1 = $v 1 + $v 2; The result can only be: Array (1,2,3,4,9)
Precedence of Operators
- Be aware that operators have priority issues
- Parentheses are the top priority, the assignment is the most backward (usually)
- First multiplication and then minus
Approximate: arithmetic operator "comparison operator" logical operator (except for "non" operation)
If statement
If Else statement:
if (conditional judgment) {
Branch 1
}
else{
Branch 2;
}
Switch statement:
Switch (a data $v1) {//To determine if this V1 variable is equal to one of the following, and if it is equal, enter the corresponding process.
Case Status value 1:
Process 1
[Break;]
Case Status Value 2:
Process 2
[Break;]
Case Status Value 3:
Process 3;
[Break;]
。。。。。。
[Default:
The default process.
]
}
Looping statements
$v 1 = 10; Initializing a loop variable
while ($v 1〉4) {//Determine the condition of the loop variable
Statement Fast
echo "ABC";
$v;
}
do{
Loop body
}while (conditional judgment);
PHP data types, operators, and process controls