php intval function, then The intval() function is a built-in function in PHP that returns the integer value of a variable.
Syntax:
int intval ( $var, $base )
Parameters:
This function accepts two parameters, one of which is required and the other One is optional.The parameters are described below:
$var: This is a required parameter and is used as a variable that needs to be converted to an integer value. $base: It is an optional parameter that specifies the base on which $var is converted to the corresponding integer. If $base is not specified. If $var contains 0x (or 0X) as a prefix, base is treated as 16. If $var contains 0, the base is 8; otherwise, the base is 10.Return value:
Returns the corresponding integer value of $var.intval() function code usage example 1:
<?php $var = '7.423'; $int_value = intval($var); echo $int_value; ?>
7
intval() function code usage example 2:
<?php $var = 0x423; $int_value = intval($var); echo $int_value; ?>
1059
intval() function code usage example 3:
<?php $var = "64"; echo intval($var)."\n".intval($var, 8); ?>
64 52
PHP Tutorial"
The above is the detailed content of How to use php intval function?. For more information, please follow other related articles on the PHP Chinese website!