English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP floatval() and doubleval() function usage and example

PHP available functions

floatval The function is used to get the floating-point value of a variable.

floatval cannot be used for arrays or objects.

Version requirement: PHP 4 >= 4.2.0, PHP 5, PHP 7.

doubleval is an alias of floatval.

Syntax

float floatval ( mixed $var )

Parameter description:

  • $var: The variable to be converted, cannot be an array or object.

Return value

The float value of the variable var.

Online Example

<?php
$var = '122.34343w3codebox';
$float_value_of_var = floatval($var);
echo $float_value_of_var; 
?>

The execution result is shown as follows:

122.34343

PHP available functions