note 127281 added to language.enumerations.backed

From: Date: Thu, 14 Jul 2022 07:36:50 +0000
Subject: note 127281 added to language.enumerations.backed
Groups: php.notes 
Request: Send a blank email to php-notes+get-219004@lists.php.net to get a copy of this message
You want to add some constants in your Enum cases? You can use class constants ! Here's an example : 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/127281 Del: integrated -- https://main.php.net/note/delete/127281/integrated Del: useless -- https://main.php.net/note/delete/127281/useless Del: bad code -- https://main.php.net/note/delete/127281/bad+code Del: spam -- https://main.php.net/note/delete/127281/spam Del: non-english -- https://main.php.net/note/delete/127281/non-english Del: in docs -- https://main.php.net/note/delete/127281/in+docs Del: other reasons-- https://main.php.net/note/delete/127281 Reject -- https://main.php.net/note/reject/127281 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219004) next »