Skip to content

Latest commit

 

History

History
79 lines (59 loc) · 1.82 KB

SplBool.md

File metadata and controls

79 lines (59 loc) · 1.82 KB

(PHP 7, PHP 8)

The SplBool class is used to enforce strong typing of the bool type.

SplBool extends SplEnum {
    /* Constants */
    public const boolean __default = false;
    public const boolean false = false;
    public const boolean true = true;
    /* Methods */
    public function __construct ([ bool $initial_value = false ])
    final public function &__invoke(): bool
    /* Inherited methods */
    public array SplEnum::getConstList ([ bool $include_default = false ])
}

SplBool::__default

SplBool::false

SplBool::true

Example #1 SplBool usage example

<?php
$true = new SplBool(true);
if ($true()) {
    echo "TRUE\n";
}

$false = new SplBool;
if ($false) {
    echo "FALSE\n";
}

The above example will output:

TRUE