Longhorn PHP 2025 - Speakers and Schedule Announced!

Tipo singleton

Los tipos singleton son aquellos que solo aceptan un único valor. PHP soporta dos tipos singleton: false desde PHP 8.0.0 y true desde PHP 8.2.0.

Advertencia

Antes de PHP 8.2.0, el tipo false solo podía ser utilizado en el contexto de un tipo union.

Nota: No es posible definir tipos singleton personalizados. Considere el uso de una enumeración en su lugar.

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