Longhorn PHP 2025 - Speakers and Schedule Announced!

Singleton types

Singleton types are those which allow only one value. PHP has support for two singleton types: false as of PHP 8.0.0 and true as of PHP 8.2.0.

Avviso

Prior to PHP 8.2.0 the false type could only be used as part of a union type.

Nota: It is not possible to define custom singleton types. Consider using an enumerations instead.

add a note

User Contributed Notes 1 note

up
1
yannick_duchene at yahoo dot fr
1 day ago
May be null could be considered to be a singleton type two. In my possibly wrong understanding, PHP has three singleton types, not just two.
To Top