Home >Backend Development >PHP Problem >How to convert string numbers into integers in php
#How to convert string numbers into integers in php?
Use PHP's built-in function intval
to convert variables.
<?php $foo = "1"; // $foo 是字符串类型 $bar = intval($foo); // $bar 是整型 ?>
The format of the intval function is: int intval(mixed $var [, int $base]);
Related references:<a href="//m.sbmmt.com" target="_blank" style="color: rgb(0, 176, 240); text-decoration: underline;"><span style="color: rgb(0, 176, 240);">php中文网</span></a>
The above is the detailed content of How to convert string numbers into integers in php. For more information, please follow other related articles on the PHP Chinese website!