PHP code example of zyimm / php-constants

1. Go to this page and download the library: Download zyimm/php-constants 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/ */

    

zyimm / php-constants example snippets


class FlowConst extends \Zyimm\PhpConstants\Constants
{
    protected static array $status = [
        'wait'  => [
            'value' => 0,
            'title' => '待审核'
        ],
        'pass'  => [
            'value' => 1,
            'title' => '通过'
        ],
        'reject' => [
            'value' => 2,
            'title' => '拒绝'
        ],
        'cancel' => [
            'value' => 3,
            'title' => '已取消'
        ]
    ];

}



FlowConst::getValueByKey('wait', 'status'); // 1
FlowConst::getValueByKey('cancel', 'status'); // 0

FlowConst::getMap('status');// [0=>'待审核', 1=> '通过' ....]

FlowConst::getMapList('status');
/**
* [ 
 * [
 *  'value' => 0,
 *  'title' => '待审核'
 * ],
 * [
 *  'value' => 1,
 *  'title' => '通过'
 * ]
 * 
 * ]
* 
* 
 */
shell
composer