PHP variable type forced conversion. That is to say, if a string value is assigned to the variable var, var becomes a string. If another integer value is assigned to var, it becomes an integer. The type in PHP is mandatory. if a string value is assigned to the variable var, var becomes a string. If another integer value is assigned to var, it becomes an integer.
The forced type conversion in PHP is very similar to that in C: add the target type enclosed in parentheses before the variable to be converted.
The code is as follows:
$ Foo = 10;
Echo "before conversion: \ $ foo =". $ foo; // output an integer
Echo"
"// Output: $ foo = 10
Echo"
";
$ Foo = (boolean) $ foo; // force convert to boolean
Echo "converted: \ $ foo =". $ foo; // output: $ foo = 1
?>
The following mandatory conversions are allowed:
(Int), (integer)-convert to integer
(Bool), (boolean)-convert to boolean
(Float), (double), (real)-convert to floating point type
(String)-convert to string
(Array)-convert to an array
(Object)-convert to object
Callback var and var are a string. If another integer value is assigned to var, it becomes an integer. Forced type in PHP...