Home >Backend Development >PHP Problem >How to convert string numbers into integers in php

How to convert string numbers into integers in php

WJ
WJOriginal
2020-06-02 13:10:173151browse

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="http://www.php.cn" 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn