is_float

is_float(mixed $value): bool

Exact float-type check: true only for the float type - int is a different type and numeric strings stay strings (is_numeric tests those); is_double is an alias.

C C23

C23
/* C types are static - no runtime is_float. C23 _Generic dispatches on
   the compile-time type: the exact-type question answered before running. */
#include <stdio.h>

#define IS_FLOAT(x) _Generic((x), double: 1, float: 1, default: 0)
#define IS_INT(x) _Generic((x), int: 1, default: 0)

int main(void) {
    printf("%d\n", IS_FLOAT(1.5)); /* 1.5 is a double literal */
    printf("%d\n", IS_FLOAT(1)); /* 1 is an int literal */
    printf("%d\n", IS_FLOAT(1.0f)); /* float suffix */
    printf("%d\n", IS_INT(1));
    printf("%d\n", IS_FLOAT(1.0)); /* whole value, still double */
    return 0;
}
Output
1
0
1
1
1

C++ C++26

C++26
// C++ types are static; decltype + std::is_same_v answer at compile time.
#include <iostream>
#include <type_traits>

int main() {
    std::cout << std::is_same_v<decltype(1.5), double> << "\n";
    std::cout << std::is_same_v<decltype(1), double> << "\n"; // int literal
    std::cout << std::is_same_v<decltype(1.0f), float> << "\n";
    std::cout << std::boolalpha << std::is_same_v<decltype(1), int> << "\n";
    std::cout << std::is_same_v<decltype(1.0), double> << "\n"; // still double
}
Output
1
0
1
true
true

C# v11.0.100

v11.0.100
// 'is' type patterns: exact runtime type check. Integer and double are
// distinct types; strings are never numbers (no implicit parse).
object pi = 1.5;
object one = 1;
object text = "1.5";
Console.WriteLine(pi is double);
Console.WriteLine(one is double); // int, not double
Console.WriteLine(text is double); // string, not double
Console.WriteLine(one is int);
Console.WriteLine(1.0 is double); // whole value, still double
Output
True
False
False
True
True

Go v1.27.4

v1.27.4
// reflect.TypeOf(...).Kind() is the runtime type query. int and float64
// are distinct kinds; numeric strings stay strings.
package main

import (
	"fmt"
	"reflect"
)

func main() {
	fmt.Println(reflect.TypeOf(1.5).Kind() == reflect.Float64)
	fmt.Println(reflect.TypeOf(1).Kind() == reflect.Float64) // Int kind
	fmt.Println(reflect.TypeOf("1.5").Kind() == reflect.Float64) // String kind
	fmt.Println(reflect.TypeOf(1).Kind() == reflect.Int)
	fmt.Println(reflect.TypeOf(1.0).Kind() == reflect.Float64)
}
Output
true
false
false
true
true

Java v27.0.1

v27.0.1
// instanceof on boxed values: exact runtime type. Integer and Double are
// distinct classes; strings are never numbers.
public class Main {
    public static void main(String[] args) {
        Object pi = 1.5;
        Object one = 1;
        Object text = "1.5";
        System.out.println(pi instanceof Double);
        System.out.println(one instanceof Double); // Integer, not Double
        System.out.println(text instanceof Double); // String, not Double
        System.out.println(one instanceof Integer);
        Object whole = 1.0; // box first: instanceof needs an object
        System.out.println(whole instanceof Double); // still Double
    }
}
Output
true
false
false
true
true

JavaScript v26.13.1

v26.13.1
// typeof: ONE "number" type covers int AND float - the int/float split
// PHP makes simply does not exist; strings stay strings.
console.log(typeof 1.5 === "number");
console.log(typeof 1 === "number"); // same type as 1.5!
console.log(typeof "1.5" === "string");
console.log(typeof NaN === "number"); // even NaN is a number
console.log(typeof 1.0 === "number"); // whole value, still number
Output
true
true
true
true
true

PHP v8.6.0

v8.6.0
// is_float - EXACT type check: true only for the float type. int is a
// different type; numeric strings stay strings (is_numeric tests those).
var_dump(is_float(1.5));
var_dump(is_float(1)); // int: a different type
var_dump(is_float("1.5")); // string: not a float
var_dump(is_float(NAN)); // still float-typed
var_dump(is_float(1.0)); // whole value, still float-typed
var_dump(is_double(2.5)); // is_double is an alias of is_float
var_dump(is_int(1)); // the int mirror
Output
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)

Python v3.15.2

v3.15.2
# isinstance(x, float) is the exact-type twin. int and float are distinct
# types; numeric strings stay strings (int()/float() parse them).
print(isinstance(1.5, float))
print(isinstance(1, float)) # int, not float
print(isinstance("1.5", float)) # str, not float
print(isinstance(float("nan"), float))
print(isinstance(1.0, float)) # whole value, still float
print(isinstance(1, int)) # the int mirror
Output
True
False
False
True
True
True

Rust v1.99.1

v1.99.1
// Types are static: float-ness is a compile-time fact. TypeId equality
// via a generic helper asks the question without runtime probing.
use std::any::{type_name, TypeId};

fn is_f64<T: 'static>() -> bool {
    TypeId::of::<T>() == TypeId::of::<f64>()
}

fn main() {
    println!("{}", is_f64::<f64>()); // 1.5's type
    println!("{}", is_f64::<i32>()); // 1's type
    println!("{}", is_f64::<&str>()); // "1.5" literal type
    println!("{}", type_name::<f64>());
    println!("{}", is_f64::<f64>()); // 1.0: whole value, same f64 type
}
Output
true
false
false
f64
true

TypeScript v26.13.1

v26.13.1
// typeof as in JavaScript (one number type); TS adds compile-time types
// that are erased before running - no runtime int/float split either.
console.log(typeof 1.5 === "number");
console.log(typeof 1 === "number");
console.log(typeof "1.5" === "string");
console.log(typeof NaN === "number");
const n: number = 1.0; // TS type annotation, erased at runtime
console.log(typeof n === "number");
Output
true
true
true
true
true

Language differences

PHP: is_float is true only for the float type - is_float(1) is false (int is a DIFFERENT type), is_float("1.5") is false (a string), is_float(1.0)/is_float(NAN) are true (whole-valued floats and NaN are float-typed); is_numeric is the function for "number or numeric string"; is_double is an alias of is_float (the manual’s alias page carries no deprecation - the task list’s "deprecated in 8.6" claim is unconfirmed there, recorded honestly as an alias); mirrors is_int (see the is_int entry). C/C++: types are a compile-time fact, so the question vanishes at runtime - C23 _Generic dispatches by type, C++ decltype + std::is_same_v: the question is answered before the program runs. C#: x is double (object pattern matching); 1.0 is double written directly is a preview feature - box first. Go: reflect.TypeOf(x).Kind() - Int/Float64 are distinct kinds. Java: boxed instanceof Double (Integer/Double are distinct classes). JavaScript/TypeScript: typeof has ONE numeric type, number - PHP’s int/float split simply does not exist in JS, typeof 1 === typeof 1.5 (the all-true entry output IS the teaching point). Python: isinstance(x, float); isinstance(1, float) is false (int is not a float subclass, matching the C level). Rust: types are compile-time facts; TypeId equality answers it. Teaching anchor: three schools of typing - runtime exact types in PHP/Python/Java/C# (int is not float), the single JS number type, and compile-time static typing in C/C++/Rust/Go where asking this at runtime is a category error.