PHP中将字符串转化为整数(int)、intval()、printf()。
相关推荐:《PHP教程》
int
<?php $foo = "1"; // $foo 是字符串类型 $bar = (int)$foo; // $bar 是整型 ?>
intval
<?php $foo = "1"; // $foo 是字符串类型 $bar = intval($foo); // $bar 是整型 ?>
sprintf
<?php $foo = "1"; // $foo 是字符串类型 $bar = sprintf("%d", $foo); // $bar 是字符串类型 ?>
以上就是php字符串怎么转成整数的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号