略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 枚举常量

2024-04-29

枚举常量

仅管 enum 可以包括 public、private、protected 的常量, 但由于它不支持继承,因此在实践中 private 和 protected 效果是相同的。

枚举常量可以引用枚举条目:

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

    public const 
Huge self::Large;
}
?>
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/language.enumerations.constants.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3