PHP floatval() function

Description

Gets the float value of var.

Syntax

PHP floatval() function has the following syntax.

float floatval ( mixed $var )

Parameter

  • var - scalar type to convert.

Return

The float value of the given variable. Empty arrays return 0, non-empty arrays return 1.

Example

Get the float value


<?php//w w  w .j a  va  2  s . c o m
$var = '122.34343The';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 122.34343
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions