PHP 8.1.2 Released!


(PHP 8 >= 8.1.0)

ReflectionEnum::getBackingTypeGets the backing type of an Enum, if any


public ReflectionEnum::getBackingType(): ?ReflectionType

If the enumeration is a Backed Enum, this method will return an instance of ReflectionType for the backing type of the Enum. If it is not a Backed Enum, it will return null.

Liste de param├Ętres

Cette fonction ne contient aucun param├Ętre.

Valeurs de retour

An instance of ReflectionType, or null if the Enum has no backing type.


Exemple #1 ReflectionEnum::getBackingType() example

enum Suit
Hearts 'H';
Diamonds 'D';
Clubs 'C';
Spades 'S';

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

$rBackingType $rEnum->getBackingType();


L'exemple ci-dessus va afficher :

string(6) "string"

Voir aussi

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top