This article mainly shares the knowledge of PHP data type conversion.
PHP's data type conversions are cast, and the PHP data types that are allowed to be converted are:
(int), (integer): Convert to Reshape
(float), (double), (real): Convert to floating-point type
(string): converted to a string
(bool), (Boolean): Converted to Boolean type
(array): Convert an array
(object): Convert to Object
There are three ways to convert PHP data types:
(1) Precede the variable to be converted with a target type enclosed in parentheses, for example:
(int) (BOOL) (float) (string) (array) (object) is illustrated below with an example:
(2) using 3 specific types of conversion functions, intval (), Floatval (), Strval (), the example is as follows:
(3) using the generic type conversion function Settype (mixed var,string type), the following example:
Articles you may be interested in
- How to use Curl's post submission data in PHP and get a summary of how to get Web page data
- How PHP converts BR newline characters in HTML to line breaks in text input
- How PHP converts multidimensional arrays to one-dimensional arrays
- MySQL various data table types reset the self-increment start value method
- PHP MySQL database operation class
- Powerful PHP Image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, invert)
- PHP uses Array_flip to implement array key-value Exchange to remove array duplicate values
- Introduction to the set, intersection, and difference functions of arrays in PHP
http://www.bkjia.com/PHPjc/764075.html www.bkjia.com true http://www.bkjia.com/PHPjc/764075.html techarticle This article mainly shares the knowledge of PHP data type conversion. PHP's data type conversions are cast, and the PHP data types that are allowed to be converted are: (int), (integer): Converted to ...