(PHP 8 >= 8.1.0)
ReflectionEnumBackedCase::getBackingValue — Gets the scalar value backing this Enum case
Gets the scalar value backing this Enum case.
This function has no parameters.
The scalar equivalent of this enum case.
Example #1 ReflectionEnum::getBackingValue() example
<?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
$rEnum = new ReflectionEnum(Suit::class);
$rCase = $rEnum->getCase('Spades');
var_dump($rCase->getBackingValue());
?>
The above example will output:
string(1) "S"
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant