Download the PHP package petrknap/enum without Composer
On this page you can find all versions of the php package petrknap/enum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download petrknap/enum
More information about petrknap/enum
Files in petrknap/enum
Package enum
Short Description Enumerated type for PHP
License LGPL-3.0-or-later
Homepage https://github.com/petrknap/php-enum
Informations about the package enum
Enumerated type for PHP
- What is Enum?
- Why use Enums instead of Constants?
- Usage of php-enum
- Enum declaration
- Enum usage
- Tips & Tricks
- How to install
What is Enum?
In computer programming, an enumerated type (also called enumeration or enum, or factor in the R programming language, and a categorical variable in statistics) is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language. A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value. In other words, an enumerated type has values that are different from each other, and that can be compared and assigned, but which are not specified by the programmer as having any particular concrete representation in the computer's memory; compilers and interpreters can represent them arbitrarily. -- Enumerated type - Wikipedia, The Free Encyclopedia
Why use Enums instead of Constants?
Because it is safer and less scary than using constants. Don't trust me? Let see at this code:
And now the same code with enum instead of constants:
Run composer require petrknap/enum
to install it.
You can support this project via donation.
The project is licensed under the terms of the LGPL-3.0-or-later
.