PHP code example of rickselby / consthelpers

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

    

rickselby / consthelpers example snippets


class DataRef
{
    use \ConstHelpers\Validating;

    const POINT_NORTH = 0;
    const POINT_SOUTH = 1;
    const POINT_EAST = 2;
    const POINT_WEST = 3;
    const POINT_UP = 4;
    const POINT_DOWN = 5;

    const ORIENT_NORMAL = 6;
    const ORIENT_INVERSE = 7;
}

// Get the list of constants that start with 'POINT_'
$consts = DataRef::startsWith('POINT_'));

// Validate a value against the constants starting with 'POINT_'
if (DataRef::isValidStartsWith($value, 'POINT_')) {
...

// Validate against constants matching a regular expression
if (DataRef::isValid($value, '/T.*E/')) {
...