PHP is_float() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Variables

Definition

In PHP, is_float() checks whether a variable is a floating-point number, which is a number with a decimal part. It returns true for floats and false for other types.

is_float() tests the type, not the value. The float 5.0 returns true, but the integer 5 and the string "5.0" return false. It is the preferred name for the alias is_double().

Syntax

Call is_float() with the values you need. Start with this line.

PHP
$result = is_float($value);
CallWhat it does
is_float(3.14)Returns true, because 3.14 is a float.
is_float(3)Returns false, because 3 is an integer.
is_float("3.14")Returns false, because a number in quotes is a string.

Use is_float() when you need a real float. If you also want to accept numeric strings, use is_numeric(). To turn a string into a float, use floatval().

Library declarations
PHP
is_float(mixed $value): bool

Parameters

ParameterDescription
valueRequired. The variable or value to test.

Return Value

Return ValueDescription
booltrue if the value is a float, otherwise false.

PHP Examples

Example 1 — Floats and Non-Floats

Test a decimal number, an integer, a numeric string and scientific notation.

PHP
<?php
var_dump(is_float(3.14));
var_dump(is_float(3));
var_dump(is_float("3.14"));
var_dump(is_float(1e3));

How It Works

  1. 3. 14 has a decimal point, so it is a float.
  2. 3 is a whole number, so it is an integer and the result is false.
  3. "3. 14" is in quotes, so it is a string.
  4. 1e3 is scientific notation, which PHP always treats as a float, even though its value is 1000.

Example 2 — Floats That Look Like Whole Numbers

Some values and functions give floats when you might expect integers.

PHP
<?php
var_dump(is_float(1.0));
var_dump(is_float(1));
var_dump(is_float(PHP_INT_MAX + 1));
var_dump(is_float(round(7)));

How It Works

  1. 1. 0 is written with a decimal point, so it is a float, even though it equals 1.
  2. The plain 1 is an integer.
  3. PHP_INT_MAX + 1 is too big for an integer, so PHP turns the result into a float.
  4. round() always returns a float, so is_float(round(7)) is true. Use intval() if you need an integer.

Example 3 — Converting Input Before Checking

Input from a form is a string. Convert it before you check or calculate with it.

PHP
<?php
$input = "3.14";

var_dump(is_float($input));

$number = floatval($input);
var_dump(is_float($number));

echo $number * 2, PHP_EOL;

How It Works

  1. $input is a string, so is_float($input) is false even though it contains a number.
  2. floatval() converts the string to a real float.
  3. is_float($number) is now true.
  4. You can use the float in a calculation, and 3. 14 * 2 gives 6.28.

Frequently Asked Questions

is_float() returns true if a variable is a floating-point number (a number with a decimal part) and false for any other type.
Yes. 5.0 is a float, even though its value is a whole number. The integer 5 returns false.
No. A string is a string, even when it holds a number. Use is_numeric() to check numeric strings, or convert the string with floatval().
None. is_double() is an alias of is_float(). Both return the same result, and is_float() is the preferred name.
Some operations always give floats. Division with / gives a float when it does not divide evenly, round(), floor() and ceil() always return floats, and integers that grow too large become floats.

Next: is_int()

is_int() checks whether a variable is an integer, which is a whole number with no decimal .

is_int() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful