PHP code example of gavinggordon / constantgroups

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

    

gavinggordon / constantgroups example snippets


		
	$constantgroups = new \GGG\Config\ConstantGroups();

	$constantgroups->set( ['hexcolours', 'rgbcolours', 'rgbacolours'] );

	$constantgroups->init();

	echo HEX_ORANGE;
	// Result:  #FF8000

	echo RGB_ORANGE;
	// Result:  rgba( 255, 128, 0 )

	echo RGBA_ORANGE;
	// Result:  rgba( 255, 128, 0, 1.0 )

	use \GGG\Config\ConstantGroups as ConstantGroups;
	use \GGG\Config\ConstantGroupCreator as ConstantGroupCreator;
	
	$myconstantsgroup = [
		'my application name' => 'testapp',
		'application version' => '1.4.5',
		'apphomedir' => dirname( __DIR__ )
	];
	
	$constantgroupcreator = new ConstantGroupCreator( $myconstantsgroup );
	
	ConstantGroups::create( $constantgroupcreator, 'AppData' );
	
	$constantgroups = new ConstantGroups();
	
	$constantgroups->set( ['hexcolours', 'appdata'] );
	
	$constantgroups->init();
	
	echo MY_APPLICATION_NAME;
	// Result: testapp