PHPeste 2025 - Parnaiba-PI

シングルトン型

シングルトン型は、ただひとつの値のみを受け入れる型です。 PHP はふたつのシングルトン型をサポートしています。 PHP 8.0.0 以降でサポートされた false 型と、 PHP 8.2.0 以降でサポートされた true 型です。

警告

PHP 8.2.0 より前のバージョンでは、 false型は union 型 の一部としてのみ使える型でした。

注意: カスタムのシングルトン型を定義することはできません。 そうしたい場合、列挙型(Enum) を使うことを検討してください。

add a note

User Contributed Notes 1 note

up
1
yannick_duchene at yahoo dot fr
7 days 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