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 check.


The syntax of the is_real() function is as follows:

bool is_real(mixed $var)

The function takes a single parameter, $var, which is the variable to be checked for being a float or a double. The function returns true if the variable is a float or a double, and false otherwise.

Example Usage

Here is an example of how to use the is_real() function in PHP:

$var1 = 3.14;
$var2 = 2.0;
$var3 = "hello";
echo is_real($var1) . "<br>";  // output: 1 (true)
echo is_real($var2) . "<br>";  // output: 1 (true)
echo is_real($var3) . "<br>";  // output: (false)

In this example, we define three variables: $var1 and $var2 are both floats, and $var3 is a string. We then use the is_real() function to check whether each variable is a float or a double. The output shows that $var1 and $var2 are floats or doubles (true), while $var3 is not a float or a double (false).


The is_real() function is an alias for is_float() in PHP 7, and it is deprecated. It is recommended to use is_float() instead, as it is more descriptive and less likely to be removed in future PHP versions.

Practice Your Knowledge

What does the is_real() function in PHP do?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?