No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

ReflectionEnum::getCase

(PHP 8 >= 8.1.0)

ReflectionEnum::getCaseReturns a specific case of an Enum

Description

public ReflectionEnum::getCase(string $name): ReflectionEnumUnitCase

Returns the reflection object for a specific Enum case by name. If the requested case is not defined, a ReflectionException is thrown.

PHP: ReflectionEnum::getCase - Manual Home of Manuel PHP  Contents Haut

Parameters

name

The name of the case to retrieve.

PHP: ReflectionEnum::getCase - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 ReflectionEnum::getCase() example

<?php
enum Suit
{
case
Hearts;
case
Diamonds;
case
Clubs;
case
Spades;
}

$rEnum = new ReflectionEnum(Suit::class);

$rCase = $rEnum->getCase('Clubs');

var_dump($rCase->getValue());
?>

The above example will output:

enum(Suit::Clubs)

PHP: ReflectionEnum::getCase - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function
Error Infobrol

Can not display this page of the Infobrol website

Type of error (18-01)

Unknown format specifier "&"

Please try again in a few minutes…

Return to the home page




Steph