note 127515 added to language.types.enumerations

From: Date: Sat, 20 Aug 2022 05:29:37 +0000
Subject: note 127515 added to language.types.enumerations
Groups: php.notes 
Request: Send a blank email to php-notes+get-219453@lists.php.net to get a copy of this message
Here is how to determine if a variable is an Enum. It was not described on the Enum page, but was described on the UnitEnum page. https://www.php.net/manual/en/class.unitenum.php <?php enum HogeEnum { case Foo; } $foo = HogeEnum::Foo; if ($foo instanceof UnitEnum) { print("This is Enum!\n"); } // ------------------------------ class Bar {} $bar = new Bar; var_dump(is_object($foo)); // bool(true) <-- $foo is object var_dump(is_object($bar)); // bool(true) <-- $bar is object var_dump($foo instanceof UnitEnum); // bool(true) <-- $foo is Enum var_dump($bar instanceof UnitEnum); // bool(false) <-- $bar is not Enum ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.175 (proxied: 2400:2650:5063:bf00:e86b:c397:dd14:bfad) ---- Manual Page -- https://php.net/manual/en/language.types.enumerations.php Edit -- https://main.php.net/note/edit/127515 Del: integrated -- https://main.php.net/note/delete/127515/integrated Del: useless -- https://main.php.net/note/delete/127515/useless Del: bad code -- https://main.php.net/note/delete/127515/bad+code Del: spam -- https://main.php.net/note/delete/127515/spam Del: non-english -- https://main.php.net/note/delete/127515/non-english Del: in docs -- https://main.php.net/note/delete/127515/in+docs Del: other reasons-- https://main.php.net/note/delete/127515 Reject -- https://main.php.net/note/reject/127515 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219453) next »