PHP is_float(), is_double(), is_real() Functions

PHP 可用的函数PHP Available Functions

is_float()The function is used to detect whether a variable is a float.

Alias functions:is_double(),is_real()。

Note:If you want to test whether a variable is a number or a numeric string (such as form input, which is usually a string), you must useis_numeric()。

PHP Version Requirements: PHP 4, PHP 5, PHP 7

Syntax

bool is_float ( mixed $var )

Parameter description:

  • $var: The variable to be detected.

Return Value

Returns TRUE if the specified variable is a float, otherwise returns FALSE.

Example

Example

<?php $var_name=127.55; if (is_float($var_name)) echo 'This is a floating-point value.' . PHP_EOL; else echo 'This is not a floating-point value.' . PHP_EOL; var_dump(is_float('example')); echo PHP_EOL; var_dump(is_float(85)); echo PHP_EOL; var_dump(is_float(true)); echo PHP_EOL; var_dump(is_float(array(23.3, 56, 6))); ?>

The output result is:

这是一个浮点类型的值
bool(false)

bool(false)

bool(false)

bool(false)

PHP 可用的函数PHP Available Functions

Other Extensions