2.1 Variables in PHP:
Define variable: $ variable name = value;
Variable name: The first digit after $ begins with $ must be the letter $ second digit can be a letter, a number, or an underscore. The customary variable name has a practical meaning, the second word is capitalized after the first letter--the hump is named.
Pre-defined variables: Receive data variables in $_get data volume is small, unsafe, via HTTP GET method to pass data
$_post data volume, security, through the HTTP POST way to pass data
$_request $_get+$_post, low efficiency
$_files upload variable, upload file via HTTP Post
Session: $_cookie saving data on the client
$_session saving data on the server side
Environmental information for $_server systems
2.2 Data types in PHP8
Basic data type (scalar type):
String strings must be enclosed in double quotes "" or single quotes ". The two quotation marks differ: the code in "" is executed, and the code in "does not execute, output according to ordinary characters."
Integer decimal, octal, hexadecimal, without quotation marks.
Float type float
When Boolean-type Boolean is printed, TRUE returns 1,false return null.
Composite type
Arrays Array
Objects Object
Special types
Resource Resource
Null value NULL only declares unassigned variable, assigning "" value of variable, unset (variable name)
Var_dump return type and value
2.3 Data-type conversions (implicit conversions)
Convert to Boolean:true--->1;
The following is converted to false when operating:
0 or 0.0----->false
Null character, empty array, null value----->false
Convert to Numeric type: true--->1,false---->0
Strings with E or e are converted to floating-point types.
Convert to String: null----> ""
Array----> "Array"
Object----> "Object"
Resource----> "resource# serial number"
2.4 operator
string concatenation: stitching symbol.
Arithmetic operators: +-*/%
Assignment: = + = = *=/=%=. =
Self-increment decrement operator: $i + + $i--to participate in the operation, in addition minus + + $i--$i first plus minus, then participate in the operation
Comparison operators:< > >= <= = = equals, compare values = = = identically, compare values and type! =! = = <>
Logical operators: X&&y x| | Y!x
Note: positive integers! Negative integer------>false!0------>true
The non-empty string--->false! " 0 "----->true!" 0.0 "----->false
Non-target operator: expression? True execution: false execution
2.5 Process Control
If
if (condition 1) {
Condition 1 is true when executed
}elseif (condition 2) {
Condition 2 is true when executed
}......
else{
The above conditions are not established, the implementation
}
Switch
Switch () {
Case Val: Execution code;
Case Val: Execution code;
Case Val: Execution code;
......
Default: The above conditions are not established when the implementation;
}
Difference: If can be nested, switch not.
PHP note 2.0--php variables, data types and transformations, operators, process controls