PHP Function: is_real
In PHP, the is_real function is used to determine whether a given variable is of the type “real” or “float”. It returns true if the variable is a real number, and false otherwise.
Syntax
The syntax for the is_real function is:
bool is_real ( mixed $var )
Here, $var is the variable being evaluated.
Return Value
The is_real function returns true if the variable is a real number, and false otherwise.
Examples
Let’s take a look at some examples to understand how the is_real function works:
$num1 = 3.14;
$num2 = 5;
$str = "Hello";
var_dump(is_real($num1)); // Output: bool(true)
var_dump(is_real($num2)); // Output: bool(false)
var_dump(is_real($str)); // Output: bool(false)
In the above example, $num1 is a real number, so is_real($num1) returns true. However, $num2 is an integer, and $str is a string, so both is_real($num2) and is_real($str) return false.
Important Note
It’s important to note that the is_real function is an alias of the is_float function in PHP. Both functions can be used interchangeably to check if a variable is a real number.
Summary
The is_real function in PHP is used to determine whether a variable is a real number or not. It returns true if the variable is a real number, and false otherwise. It can be used interchangeably with the is_float function. To learn more about VPS hosting solutions, visit Server.HK.