Enums and their real-world usage in PHP 8.1

Опубликовано: 13 Февраль 2022
на канале: Amit Merchant
916
23

With the introduction of PHP 8.1 comes the Enumerations (or "enums" in short) in PHP natively. Enums or enumerations or enumerator types are those little data structures that can be used to define a set of named values.

You can use an Enum to represent a smallish fixed set of constants or an internal class mode while increasing readability.

We'll learn all about Enums in PHP and their real-world usage in this video. So, sit tight and enjoy!

Companion article: https://www.amitmerchant.com/native-e...

Step up your game with PHP with my book "PHP 8 in a Nutshell": https://amitmerchant.gumroad.com/l/ph...

You can follow me on Twitter:   / amit_merchant  

00:00 - Introduction
03:00 - Enums in PHP 8.1
04:44 - Fetch enum case name
05:45 - Backed enums
08:11 - Enum methods
09:16 - type-checking with Enums
10:36 - Fetch all enum cases
11:36 - A real-world example