0
点赞
收藏
分享

微信扫一扫

PHP中将字符串转化为整数(int) intval() printf()


int



1 <?php 
2 $foo = "1"; // $foo 是字符串类型
3 $bar = (int)$foo; // $bar 是整型
4 ?>



intval



1 <?php 
2 $foo = "1"; // $foo 是字符串类型
3 $bar = intval($foo); // $bar 是整型
4 ?>



sprintf



1 <?php 
2 $foo = "1"; // $foo 是字符串类型
3 $bar = sprintf("%d", $foo); // $bar 是字符串类型
4 ?>

举报

相关推荐

0 条评论