php如何将float转int?

2020-08-12 22:04:52

php如何将float转int?

1、使用函数“intval”将float类型数据转为int类型;

$float = 15.222;intval($float);

2、使用“settype()”将float类型数据设置为int类型;

$float = 15.222;settype($float, 'int');

3、在变量前面加上“ (int)”,将其进行强制转换为int。

$float = 15.222;(int) $float;
相关文章 大家在看