How to convert string to int: 1. Use the [parseInt()] method in the Integer class to convert String to int; 2. Use the [valueOf()] and [intValue()] in the Integer class Method; 3. First judge the regular expression and dynamically select the method to convert the data.
String to int method:
1. String to int method 1, use parseInt in the Integer class ()method.
2. String to int method 2, use the valueOf() and intValue() methods in the Integer class.
#3. Use regular expressions to determine whether String is integer or floating-point data. Dynamically select methods to transform data.
Related learning recommendations: php programming (video)
The above is the detailed content of What are the methods of converting string to int?. For more information, please follow other related articles on the PHP Chinese website!