note 128919 added to language.enumerations.constants

From: Date: Wed, 27 Sep 2023 08:19:52 +0000
Subject: note 128919 added to language.enumerations.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-220878@lists.php.net to get a copy of this message
Just to clarify, enum constants *can* contain cases, but they don't *have* to; other constant values are legitimate - including cases of other Enumerations. <?php enum Suit { case Hearts; case Clubs; case Spades; case Diamonds; public const Card = Size::Large; // A case from a different enum } enum Size { case Small; case Medium; case Large; public const Scale = 297/210; // A float } echo Suit::Diamonds::Card::Scale; // Getting the constant Scale from the constant Card in a Suit. ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 222.153.168.209) ---- Manual Page -- https://php.net/manual/en/language.enumerations.constants.php Edit -- https://main.php.net/note/edit/128919 Del: integrated -- https://main.php.net/note/delete/128919/integrated Del: useless -- https://main.php.net/note/delete/128919/useless Del: bad code -- https://main.php.net/note/delete/128919/bad+code Del: spam -- https://main.php.net/note/delete/128919/spam Del: non-english -- https://main.php.net/note/delete/128919/non-english Del: in docs -- https://main.php.net/note/delete/128919/in+docs Del: other reasons-- https://main.php.net/note/delete/128919 Reject -- https://main.php.net/note/reject/128919 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220878) next »