note 127278 added to language.enumerations.backed
| From: | Aym at main dot php dot net | Date: | Wed, 13 Jul 2022 20:38:59 +0000 |
| Subject: | note 127278 added to language.enumerations.backed | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219000@lists.php.net to get a copy of this message | ||
You want to add some constants on Enum case? You can use class constant(only if their value is not a
global constant)!
Here's an example :
<?php
class Something
{
const PARENT = 'parent';
}
enum MyEnum:string
{
case firstChild = Something::PARENT . '_child1';
case secondChild = Something::PARENT . '_child2';
}
echo MyEnum::firstChild->value; // print "parent_child1"
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 83.197.242.226)
----
Manual Page -- https://php.net/manual/en/language.enumerations.backed.php
Edit -- https://main.php.net/note/edit/127278
Del: integrated -- https://main.php.net/note/delete/127278/integrated
Del: useless -- https://main.php.net/note/delete/127278/useless
Del: bad code -- https://main.php.net/note/delete/127278/bad+code
Del: spam -- https://main.php.net/note/delete/127278/spam
Del: non-english -- https://main.php.net/note/delete/127278/non-english
Del: in docs -- https://main.php.net/note/delete/127278/in+docs
Del: other reasons-- https://main.php.net/note/delete/127278
Reject -- https://main.php.net/note/reject/127278
Search -- https://main.php.net/manage/user-notes.php