PHP Classes

Constant Management class: Define constant values that can be updated

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2005-10-26 (10 years ago) RSS 2.0 feedStarStarStarStar 63%Total: 1,348 All time: 2,779 This week: 1,070Up
Version License Categories
constmgr 1.0GNU General Publi...Data types
Description Author

This is a simple class that can be used to define constant values that can be updated.

It can store and retrieve values from global variables with unique names based on a constant name key. If the constant is already defined, the class can update its value.

Picture of Svetoslav Marinov
  Performance   Level  
Name: Svetoslav Marinov is available for providing paid consulting. Contact Svetoslav Marinov .
Classes: 6 packages by
Country: Canada Canada
Age: 35
All time rank: 705 in Canada Canada
Week rank: 893 Down20 in Canada Canada Down
Innovation award
Innovation award
Nominee: 3x

Winner: 1x


1. description
2. example
3. author
4. credits
5. conclusion

1. description

constmgr is used to define constants and update their values on the fly.

1) make an instance of constmgr class

2) you MUST set/define constants using the constmgr class

3) accessing the value:
	$obj->get( "DRAGON" );

	possible common mistakes

	1) accessing directly: SOME_CONSTANT after its definition with constmgr class
			$obj =& new constmgr();

			// this method call won't update the value
			$obj->set( "DRAGON", "DRAGON value" );

			// WRONG! way
			print "defined const:" . DRAGON . "\n";

			// RIGHT! ways

			// 1)
			print "New value:" . ${DRAGON} . "\n"; // always use this style to access the new value

			// 2)
			print "Get: " . $obj->get( "DRAGON" ). "\n\n";

	2) defining SOME_CONSTANT before defining it with constmgr class


		define( "DRAGON", "first DRAGON value" );

		$obj =& new constmgr();

		// this method call won't update the value
		$obj->set( "DRAGON", "DRAGON value" );

2. example

please check the example file in the same directory

3. author

Svetoslav Marinov <>

He is studying computer sciences and technologies in technical university of Sofia, Bulgaria.
He has also a master degree in Electrical Engineering department in same university.

At this moment he works for a big hosting company. In his free time
he works on - Developers' quick reference site which contains
( in future ) useful code snippets,tips,tricks etc.

bugs,comments,improvements are always welcome.

4. credits

	I was inspired to made this class when checking php's online docs at

	************************** example **************************
	rafael at fuchs inf br
	21-Mar-2005 11:08
	You can use constants in variable variables, like I show below. This works fine:

	$Fuchs = "Test";

	echo TEST . "<BR>";
	echo ${TEST};


	************************** example **************************

5. conclusion

	when accessing constants with style like this one ${DRAGON} may be a little bit
	annoying for you but it is a matter of choice.

	if you find this package useful use it.

	all the best!

  Files folder image Files  
File Role Description
Accessible without login Plain text file README-BG.TXT Doc. Readme file (Bulgarian Version)
Accessible without login Plain text file constmgr-example.php Example example file for constant management class
Plain text file constmgr.class.php Class constant management class
Accessible without login Plain text file README.TXT Doc. readme file for constant management class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:2,779
This week:1,070Up
User Ratings User Comments (2)
 All time
Its worth nothing to explain that an object messing with the ...
4 years ago (Rodrigo Contreras K.)
7 years ago (kishore kumar)