W3docs

is_real()

The is_real() function in PHP 7 checks whether a variable is a float or a double. It is a deprecated alias for the is_float() function, which performs the same

Introduction

is_real() is an alias of is_float(). Both check whether a variable holds a floating-point value (PHP uses a single float type — "real" and "double" are just other names for the same thing). The function returns a boolean: true for floats, false for everything else.

The name comes from the mathematical term real number. Because PHP already has the clearer, more standard is_float(), the is_real() alias was deprecated in PHP 7.4 and removed entirely in PHP 8.0. On a modern PHP install, calling is_real() raises a fatal Error: Call to undefined function.

This page exists so you understand legacy code that still uses it — but in anything you write today, use is_float().

Syntax

is_real(mixed $value): bool
  • $value — the variable to test.
  • Returnstrue if $value is of type float, otherwise false.

Note: this function only tests the type. A numeric string such as "3.14" is a string, not a float, so it returns false. To accept numeric strings too, use is_numeric().

Example: how is_real() behaves

<?php
$float    = 3.14;
$whole    = 2.0;      // still a float, despite the round value
$integer  = 5;
$text     = "3.14";   // a numeric string, not a float

var_dump(is_real($float));    // bool(true)
var_dump(is_real($whole));    // bool(true)
var_dump(is_real($integer));  // bool(false)  — this is an int
var_dump(is_real($text));     // bool(false)  — this is a string
?>

2.0 is a float even though its value is a whole number, so it passes. The integer 5 and the string "3.14" both fail, because is_real() checks the underlying type, not the value.

Be careful when printing the result directly: echo turns true into "1" and false into an empty string, which can look like nothing happened. Use var_dump() while debugging so you can see true/false clearly.

The modern equivalent

Replacing is_real() is a one-to-one swap — just rename the call:

<?php
$price = 19.99;

if (is_float($price)) {
    echo "It's a float.";
} else {
    echo "Not a float.";
}
// Output: It's a float.
?>

If you maintain code that must run on PHP 8 but still references is_real(), a safe shim is:

<?php
if (!function_exists('is_real')) {
    function is_real($value): bool {
        return is_float($value);
    }
}
?>

PHP ships a family of is_* functions for runtime type checks:

Conclusion

is_real() was an alias for is_float() and is no longer available as of PHP 8.0. It checks whether a value is of type float, returning true or false. In new code always call is_float() directly; reach for is_numeric() if numeric strings should also count.

Practice

Practice
What does the is_real() function in PHP do?
What does the is_real() function in PHP do?
Was this page helpful?