Sunday, August 2, 2026
HomeLanguagesPHP | is_real() Function

PHP | is_real() Function

The is_real() function is an inbuilt function in PHP which is used to check the given value is a real number or not.

Syntax:

bool is_real( mixed $var )

Parameters: This function accepts one parameter as mentioned above and described below:

  • $var: It contains the value of variable that need to be check.

Return Value: It returns TRUE if the given value of variable is real number, FALSE otherwise.

Program 1:




<?php 
// PHP code to demonstrate
// the is_real() function
  
function square($num) { 
    return (is_real($num)); 
} 
  
var_dump(square(9.09)); 
var_dump(square(FALSE));
var_dump(square(14));
var_dump(square(56.30));
  
?> 


Output:

bool(true)
bool(false)
bool(false)
bool(true)

Program 2:




<?php 
// PHP program to demonstrate the
// is_real() function
  
$variable_name1 = 67.099; 
$variable_name2 = 32; 
$variable_name3 = "abc"; 
$variable_name4 = FALSE; 
  
// Check given variable is real number or not
if (is_real($variable_name1)) 
    echo "$variable_name1 is a real value. \n"; 
else
    echo "$variable_name1 is not a real value. \n"; 
  
// Check given variable is real number or not
if (is_float($variable_name2)) 
    echo "$variable_name2 is a real value. \n"; 
else
    echo "$variable_name2 is not a real value. \n"; 
  
// Check given variable is real number or not 
if (is_float($variable_name3)) 
    echo "$variable_name3 is a real value. \n"; 
else
    echo "$variable_name3 is not a real value. \n"; 
  
// Check given variable is real number or not
if (is_float($variable_name4)) 
    echo "FALSE is a real value. \n"; 
else
    echo "FALSE is not a real value. \n"; 
?> 


Output:

67.099 is a real value. 
32 is not a real value. 
abc is not a real value. 
FALSE is not a real value.

Reference: https://www.php.net/manual/en/function.is-real.php

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6981 POSTS0 COMMENTS
Umr Jansen
6973 POSTS0 COMMENTS