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

How to convert string numbers into integers in php

WJ
Release: 2023-03-01 11:36:01
Original
3137 people have browsed it

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 是整型 
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template