PHP | intval() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report The intval() function is an inbuilt function in PHP which returns the integer value of a variable. Syntax: int intval ( $var, $base ) Parameters: This function accepts two parameters out of which one is mandatory while the other one is optional. Parameters are described below: $var: It is a mandatory parameter serves as the variable which needs to be converted to its integer value. $base: It ia a optional parameter specifies the base for conversion of $var to its corresponding integer. If $base is not specified. If $var contains 0x (or 0X) as prefix, the base is taken as 16. If $var starts with 0, the base is taken as 8 Otherwise, the base is taken as 10. Return Value: It returns the corresponding integer value of $var. Examples: Input : $var = '120', $base = 8 Output : 80 Input : $var = 0x34 Output : 52 Input : $var = 034 Output : 28 Below programs illustrate the use of intval() function in PHP: Program 1: php <?php $var = '7.423'; $int_value = intval($var); echo $int_value; ?> Output: 7 Program 2: php <?php $var = 0x423; $int_value = intval($var); echo $int_value; ?> Output: 1059 Program 3: php <?php $var = "64"; echo intval($var)."\n".intval($var, 8); ?> Output: 64 52 Reference: https://www.php.net/manual/en/function.intval.php Create Quiz Comment R RICHIK BHATTACHARJEE Follow 1 Improve R RICHIK BHATTACHARJEE Follow 1 Improve Article Tags : Misc Web Technologies PHP PHP-function Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like