note 126728 added to language.enumerations.backed
| From: | sajjad dot golchin at main dot php dot net | Date: | Thu, 30 Dec 2021 00:45:36 +0000 |
| Subject: | note 126728 added to language.enumerations.backed | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217441@lists.php.net to get a copy of this message | ||
<?php
enum Colors: string
{
case Red_key = 'red';
case Blue_key = 'blue';
case Green_key = 'green';
public function getColor(): string
{
return $this->name . ':' . $this->value ;
}
}
function paintColor(Colors $colors): void
{
echo "Paint => " . $colors->getColor() . PHP_EOL;
}
paintColor(Colors::Red_key);
paintColor(Colors::Green_key);
paintColor(Colors::Blue_key);
/*
output :
------------------------
Paint => Red_key:red
Paint => Green_key:green
Paint => Blue_key:blue
*/
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 2a01:5ec0:2000:c350:7bf8:e248:ca5d:8b2d)
----
Manual Page -- https://php.net/manual/en/language.enumerations.backed.php
Edit -- https://main.php.net/note/edit/126728
Del: integrated -- https://main.php.net/note/delete/126728/integrated
Del: useless -- https://main.php.net/note/delete/126728/useless
Del: bad code -- https://main.php.net/note/delete/126728/bad+code
Del: spam -- https://main.php.net/note/delete/126728/spam
Del: non-english -- https://main.php.net/note/delete/126728/non-english
Del: in docs -- https://main.php.net/note/delete/126728/in+docs
Del: other reasons-- https://main.php.net/note/delete/126728
Reject -- https://main.php.net/note/reject/126728
Search -- https://main.php.net/manage/user-notes.php