int intval (mixed $var [, int $base]) by using a specific binary conversion (default is decimal), the parameter base represents the binary, and only if Var is a string, base will make sense, which means to convert Var by base, return the variable The integer value of var.
Intval (), if the argument is a string, the integer value represented by the number string before the first character in the string that is not a number is returned. If the first string of strings is '-', the second begins. If the argument is a number of character points, the value after the rounding is returned. When Var is an array, VAR returns 0 if it is empty, and 1 is returned.
For example: Intval ("12AB3") returns 12
Intval ("ab123") returned is 0
Intval (" -1AB2") returned is-1
Intval (12.3223) =12
Intval ("100", 2) = 4 100 According to 2 is 4
Intval (Array ()) = 0
Intval (Array) = 1
=======================================
The effect of int () is the same as intval, but the efficiency seems not as high as intval
=======================================
If you need to determine whether a string is a pure number, you cannot use the Intval conversion, you must use Is_numeric ($var) and return True if Var is a pure number, otherwise false
Is_numeric ("12a") = False
Is_numeric ("123") = True
Is_numeric ("9.2") = True
=======================================
Regular expressions can also be used to determine the preg_match of a pure number(‘/^\d+$/i‘, $var)
Intval () and int ()