Php Data type conversion. This article mainly shares the knowledge of PHP Data type conversion. PHP Data type conversion is a forced conversion. The PHP Data types that can be converted include: (int) and (integer). This article mainly shares the knowledge of PHP Data type conversion.
PHP Data type conversion is a forced conversion. The PHP Data types that can be converted include:
(Int), (integer): convert to integer
(Float), (double), (real): convert to floating point type
(String): convert to a string
(Bool), (boolean): convert to boolean type
(Array): convert to an array
(Object): convert to object
There are three conversion methods for PHP Data types:
(1) add the target type enclosed in parentheses before the variable to be converted, for example:
(Int) (bool) (float) (string) (array) (object) is described in the following example:
(2) use three types of conversion functions: intval (), floatval (), and strval (). The example is as follows:
(3) use the common type conversion function settype (mixed var, string type). The example is as follows:
Articles you may be interested in
- In php, we use the curl post method to submit data and the get method to obtain webpage data.
- How does php convert the br line breaks in html to line breaks in text input?
- Php converts a multi-dimensional array to a one-dimensional array
- Methods for resetting the auto-increment start value of various MySQL data table types
- Php mysql database operations
- Powerful PHP image processing class (Watermark, transparency, zoom, sharpen, rotate, flip, cut, reversed)
- Php uses array_flip to implement array key-value exchange to remove array duplicate values
- Introduction to array union, intersection, and difference set functions in php
Bytes. PHP Data type conversion is a forced conversion. The PHP Data types that can be converted include: (int) and (integer): converted...