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::getBackingType

(PHP 8 >= 8.1.0)

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

Description

public ReflectionEnum::getBackingType(): ?ReflectionNamedType

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.

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

Return Values

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

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

Changelog

Version Description
8.2.0 The return type is now declared as ?ReflectionNamedType. Previously, ?ReflectionType was declared.

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

Examples

Example #1 ReflectionEnum::getBackingType() example

<?php
enum Suit
: string
{
case
Hearts = 'H';
case
Diamonds = 'D';
case
Clubs = 'C';
case
Spades = 'S';
}

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

$rBackingType = $rEnum->getBackingType();

var_dump((string)$rBackingType);
?>

The above example will output:

string(6) "string"

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