略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: enum_exists

2024-04-29

enum_exists

(PHP 8 >= 8.1.0)

enum_exists检测是否定义对应的枚举

说明

enum_exists(string $class, bool $autoload = true): bool

本函数检测是否定义指定的枚举。

参数

enum

枚举的名称。名称的匹配不区分大小写。

autoload

是否默认调用 __autoload

返回值

如果 enum 已定义,返回 true,否则就返回 false

范例

示例 #1 enum_exists() 例子

<?php
// 在使用之前检测枚举是否存在
if (enum_exists(Suit::class)) {
    
$myclass Suit::Hearts;
}
?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.enum-exists.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3