php如何将float转int?

Guanhui
Guanhui 原创
2023-03-02 21:18:01 3967浏览

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;

推荐教程:《PHP

以上就是php如何将float转int?的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。