PHP is a weakly typed language, meaning that variables do not need to be declared as specific data types, so it is important to do ' type handling ' during code writing.
Processing method:
1, detection type;
2. Type of conversion;
3. Rely on good and clear documentation.
PHP type check function:
| Type check function |
Type |
Describe |
| Is_bool () |
Boolean type |
Value is True or False |
| Is_integer () |
Integral type |
Integer |
| Is_double () |
Double-precision Type |
Floating point number |
| Is_string () |
String |
Character data |
| Is_object () |
Object |
Object |
| Is_array () |
Array |
Array |
| Is_resource () |
Resources |
Handles for identifying and processing external resources, such as database files |
| Is_null () |
Null |
Unassigned Value |
Note:PHP Converts a non-empty string value to a Boolean value when testing a variable to true
if (' false ') {
// ......
}
is equivalent to
if (true) {
// ......
}
PHP Basic Types