首页  >  文章  >  后端开发  >  php如何将float转int?

php如何将float转int?

Guanhui
Guanhui原创
2020-07-22 11:28:404747浏览

php如何将float转int?

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