Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Enumerations/PHP/enumerations.php
Normal file
18
Task/Enumerations/PHP/enumerations.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Using an array/hash
|
||||
$fruits = array( "apple", "banana", "cherry" );
|
||||
$fruits = array( "apple" => 0, "banana" => 1, "cherry" => 2 );
|
||||
|
||||
// If you are inside a class scope
|
||||
class Fruit {
|
||||
const APPLE = 0;
|
||||
const BANANA = 1;
|
||||
const CHERRY = 2;
|
||||
}
|
||||
|
||||
// Then you can access them as such
|
||||
$value = Fruit::APPLE;
|
||||
|
||||
// Or, you can do it using define()
|
||||
define("FRUIT_APPLE", 0);
|
||||
define("FRUIT_BANANA", 1);
|
||||
define("FRUIT_CHERRY", 2);
|
||||
Loading…
Add table
Add a link
Reference in a new issue