PHP code example of jayzeng / php-enum
1. Go to this page and download the library: Download jayzeng/php-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/ */
jayzeng / php-enum example snippets
class StubUtilEnum extends Enum
{
const ONE = 1;
const TWO = 2;
const THREE = 3;
const FOUR = "four";
}
// Retrieve value mapped to the label
$StubUtilEnum->getValue('ONE'); // returns 1
$StubUtilEnum->getValue('FOUR'); // returns four
$StubUtilEnum->getValues(); // array
// Determine if a label exists
$StubUtilEnum->hasLabel(1); // true
$StubUtilEnum->hasLabel('oops'); // false