Introduction
In this article I explain the Intval() function in PHP. The Intval() function returns the integer value of a variable. You can not use the intval() function on an object.
Syntax
|
intval($var_name,base); |
| Parameter | Description |
| Var name | Scalar value to be converted into an integer |
| Base | Base for the conversion |
The default base is ten.
Example
In the following example, the empty array returns the output zero and the nonempty array returns the one:
<html>
<body bgcolor="#FFFFCC">
<?php
echo intval(33)."<br>";
echo intval(3.4)."<br>";
echo intval('31')."<br>";
echo intval('+321')."<br>";
echo intval('-313')."<br>";
echo intval(0213)."<br>";
echo intval('032')."<br>";


Comments
Join the conversation! Your thoughts help the community grow.