PHP is_real() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Variables

Definition

In PHP, is_real() was an old alias of is_float() that checked whether a value is a floating point number. It was deprecated in PHP 7.4 and removed completely in PHP 8.0.

If you call is_real() on PHP 8 or later, you get a fatal error because the function no longer exists. The fix is easy: replace every is_real() with is_float(), which does the same job. This page teaches the replacement and shows how it behaves.

Syntax

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

PHP
$ok = is_float($value); // use is_float(), not is_real()
CallWhat it does
is_real(1.5)Removed. On PHP 8.0 or later this causes a fatal error: Call to undefined function is_real().
is_float(1.5)Returns true. This is the correct replacement for is_real().
is_float(10)Returns false because 10 is an integer, not a float.

is_real() was deprecated in PHP 7.4 and removed in PHP 8.0. The replacement is is_float(). The alias is_double() still works, but is_float() is the recommended name.

Library declarations
PHP
is_real(mixed $value): bool  // removed in PHP 8.0, use is_float()

Parameters

ParameterDescription
valueRequired. The value you want to check. In the replacement is_float(), it can be of any type.

Return Value

Return ValueDescription
boolIn old PHP versions it returned true for floats. On PHP 8.0 or later the function does not exist, so use is_float(), which returns true for floats and false for everything else.

PHP Examples

Example 1 — The Replacement: is_float()

Use is_float() wherever old code used is_real(). Test a decimal, a float zero and an integer.

PHP
<?php
var_dump(is_float(1.5));
var_dump(is_float(0.0));
var_dump(is_float(10));

How It Works

  1. 1. 5 has a decimal part. It is a float, so is_float() returns true.
  2. 0. 0 is still a float. The type is decided by the decimal point, not by the value.
  3. 10 is an integer. It has no decimal part in PHP's type system, so the result is false.
  4. These are the same answers is_real() gave in PHP 7. Only the function name changed.

Example 2 — Strings and Division Results

Look at tricky cases: a numeric string, scientific notation and the results of division.

PHP
<?php
var_dump(is_float('1.5'));
var_dump(is_float(1e3));
var_dump(is_float(10 / 4));
var_dump(is_float(10 / 5));

How It Works

  1. '1. 5' is a string. The quotes make it text, so the result is false.
  2. 1e3 is a float literal. Scientific notation always creates a float, even though it equals 1000.
  3. 10 / 4 gives 2. 5. The answer has a decimal part, so it is a float.
  4. 10 / 5 gives exactly 2. PHP returns an int when a division has no remainder, so the result is false.

Example 3 — Migrating Old Code and History

Check on PHP 8 that is_real() is gone and is_float() works. Older code from PHP 7 and earlier used is_real().

PHP
<?php
// PHP 7 and earlier: is_real($price)
// PHP 8 and later:   is_float($price)
$price = 19.99;

echo function_exists('is_real') ? 'is_real exists' : 'is_real is gone', PHP_EOL;
echo function_exists('is_float') ? 'is_float exists' : 'is_float is missing', PHP_EOL;
echo is_float($price) ? 'Price is a float' : 'Price is not a float', PHP_EOL;

How It Works

  1. The comments show the history. Old code used is_real(), and new code uses is_float().
  2. function_exists() tests for a function by name. On PHP 8 it reports that is_real() is gone.
  3. is_float() is still there. It is the permanent, supported name for this check.
  4. The price 19. 99 is a float. So the last line prints Price is a float using the new function.

Frequently Asked Questions

is_real() was an alias of is_float(). PHP deprecated it in version 7.4 and removed it in PHP 8.0, so calling it on a modern version causes a fatal error.
Use is_float(). It checks the same thing, and it works in every PHP version, old and new. You can replace is_real( with is_float( directly.
The name was confusing, because PHP has no 'real' type, only float. Removing the extra aliases made the language more consistent.
Yes. is_double() is still an alias of is_float() and works in PHP 8. Even so, is_float() is the name you should prefer in new code.
Search all your files for is_real( and replace each match with is_float(. Running the code on PHP 7.4 also shows a deprecation notice for each call, which helps you find them.

Next: is_resource()

is_resource() checks whether a value is an open resource. A resource is a special handle t.

is_resource() 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