Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

boolval()

Convert a value to its boolean interpretation before combining flags.

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

Syntax

boolval(mixed $value): bool

Convert a value to its boolean interpretation before combining flags. Both the empty string and exactly "0" convert to false, whereas "false" and "00" convert to true. A nonempty array is true even when its only element is false.

Signature

boolval(mixed $value): bool

Example output

[false,false,true,true,false,true]

Examples

<?php
echo json_encode(array_map("boolval", ["", "0", "false", "00", [], [false]]));

Result

[false,false,true,true,false,true]

Sources