php method to convert characters into numbers: You can use specific types of conversion functions, such as intval(), floatval(), strval(), etc. The intval() function is used to get the integer value of a variable. The floatval() function is used to obtain the floating point value of a variable.
Function introduction:
(Recommended tutorial: php graphic tutorial)
intval( ) function is used to obtain the integer value of a variable.
intval() function returns the integer value of variable var by using the specified base conversion (default is decimal). intval() cannot be used with object, otherwise an E_NOTICE error will be generated and 1 will be returned.
floatval function is used to obtain the floating point value of a variable.
strval() function is used to get the string value of a variable.
The method is as follows:
Conversion method 1: Add the target type enclosed in parentheses before the variable to be converted, such as (int); (bool); (float); (string ); (array); (object)
Conversion method two: use three specific types of conversion functions, intval(); floatval(); strval()
(Video tutorial recommendation: php video tutorial)
Conversion method three: settype();
The above is the detailed content of How to convert characters to numbers in php. For more information, please follow other related articles on the PHP Chinese website!