#How to convert string to int in php?
Convert string to integer (int) intval() printf()
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 tutorial"
The above is the detailed content of How to convert string to int in php. For more information, please follow other related articles on the PHP Chinese website!