Enumeration constants

Enumerations may include constants, which may be public, private, or protected, although in practice private and protected are equivalent as inheritance is not allowed.

An enum constant may refer to an enum case:

<?php
enum Size
{
    case 
Small;
    case 
Medium;
    case 
Large;

    public const 
Huge self::Large;
}
?>

User Contributed Notes

There are no user contributed notes for this page.
PHP8中文手册 站长在线 整理 版权归PHP文档组所有