PHP code example of fatcode / enum

1. Go to this page and download the library: Download fatcode/enum library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fatcode / enum example snippets




use  FatCode\Enum;

class Colors extends Enum
{
    public const RED = 'red';
    public const GREEN = 'green';
    protected const INVISIBLE_COLOR = 'invisible_color';
}


// $red is instance of Enum with value 'red'
$red = Colors::RED();
$red->getValue(); // "red"
$red->getKey();// "RED"