gmp_intval() function in PHP


The gmp_intval() function returns the integer value of a variable.

Syntax

intval ( $var, $base )

Parameters

  • var − The variable which needs to be converted to its integer value.

  • base − The base for conversion of $var to its corresponding integer.

Return

The gmp_intval() function returns the integer value for var.

Example

 Live Demo

The following is an example −

<?php
   $var = "180";
   echo intval($var, 8);
?>

Output

The following is the output −

1

Updated on: 30-Jun-2020

17 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements