PHP intval() Function

PHP is_array() Function
PHP gettype() Function

In this article, you will learn how to get the integer value of a variable in PHP. The intval() function in PHP returns the integer value of a variable.

what is the syntax of the INTVAL() function in php?

intval(variable, base);
ParametersDetails
variableRequired. Specifies the variable to check
baseOptional. Specifies the base to use for the conversion. Only has effect if variable is a string. Default base is 10
PHP intval() method

examples of the INTVAL() function

Example 1. In this example, we 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>";
?>
PHP is_array() Function
PHP gettype() Function
en English
X
Scroll to Top