❮ PHP Variable Handling Reference
Return the integer value of different variables:
<?php
$a = 32;
echo intval($a) . "<br>";
$b = 3.2;
echo intval($b) . "<br>";
$c = "32.5";
echo intval($c) . "<br>";
$d = array();
echo intval($d) . "<br>";
$e = array("red", "green", "blue");
echo intval($e) . "<br>";
?>
Try it Yourself »
The intval() function returns the integer value of a variable.
intval(
variable,
base);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
base | Optional. Specifies the base to use for the conversion. Only has effect if variable is a string. Default base is 10 |
Return Value: | The integer value of the variable on success, 0 on failure. An empty array will return 0, and a non-empty array will return 1 |
---|---|
Return Type: | Integer |
PHP Version: | 4.0+ |
PHP Changelog: | PHP 5.1: When an object is passed to variable, it throws E_NOTICE and returns 1 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!