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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP is_float(), is_double(), is_real() Function Usage and Example

PHP Available Functions

is_float() The function is used to check whether a variable is a floating-point type.

Alias Functions:is_double(), is_real().

Note: To test whether a variable is a number or a numeric string (such as form input, which is usually a string), you must use is_numeric().

PHP Version Requirement: PHP 4, PHP 5, PHP 7

Syntax

bool is_float ( mixed $var )

Parameter Description:

  • $var: The variable to be checked.

Return Value

If the specified variable is float, it returns TRUE; otherwise, it returns FALSE.

Online Example

<?php
$var_name=127.55;
if (is_float($var_name))
    echo 'This is a floating-point value' . PHP_EOL;
else
    echo 'This is not a floating-point value' . PHP_EOL;
var_dump(is_float('w3codebox
echo PHP_EOL;
var_dump(is_float(85));
echo PHP_EOL;
var_dump(is_float(true));
echo PHP_EOL;
var_dump(is_float(array(23.3, 56, 6);
?>

The output result is:

This is a floating-point value
bool(false)
bool(false)
bool(false)
bool(false)

PHP Available Functions