Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

is_bool()

Validate a strictly boolean flag without casting it.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

is_bool(mixed $value): bool

Validate a strictly boolean flag without casting it. Both true and false satisfy the check, but the integer zero and the string "false" do not. This distinguishes an explicit false setting from an input of the wrong type.

Signature

is_bool(mixed $value): bool

Example output

[true,true,false,false,false]

Examples

<?php
echo json_encode(array_map("is_bool", [true, false, 0, "false", null]));

Result

[true,true,false,false,false]

Sources