Home > Article > Backend Development > Type conversion, constant definition, operators, several cases of false
【Forced Type Conversion】
1. The value of null converted to integer type is 0;
2. The value of null converted to floating point type becomes 0 of floating point type;
3. Empty is converted into a string and becomes an empty string '', with no characters in the middle, including spaces;
4. If there is a string behind the integer, only the previous number will be output;
5. There is a string after the floating point type, and only the previous number including the decimal point is output.
【Constant】
Definition format: define ('constant name', 'constant value' ');
1. Cannot be defined repeatedly
2. Constant names generally use uppercase letters
3. The scope is global
4. Constants The value can only be a scalar
5. No $ sign when output
6. Constants cannot be written into strings
Determine whether the constant is defined: defined('constant name');
【Operator】
It should be noted that: == determines whether the values are equal === determines whether the values and data types are equal
【is false Several situations]
1. Integer type 0 is false when judging, integer type 2,3,4...are true
2. Floating point type 0.0000 is false, it is true if there are non-zero numbers
3. The empty string is false, and there are characters (including spaces) in the middle, which is true
4. The empty string is false, and there are Characters (including spaces) are true
5. An empty array is false
6. Null as a judgment condition is false
if(条件为真) { 执行 }
True is 1, false is 0
The above is the detailed content of Type conversion, constant definition, operators, several cases of false. For more information, please follow other related articles on the PHP Chinese website!