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    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 63%Total: 1,355 This week: 1All time: 2,862 This week: 560Up
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 <contact>
Classes: 7 packages by
Country: Canada Canada
Age: 42
All time rank: 715 in Canada Canada
Week rank: 106 Down3 in Canada Canada Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Details

constmgr 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: ${SOME_CONSTANT} or $obj->get( "DRAGON" ); Note: possible common mistakes 1) accessing directly: SOME_CONSTANT after its definition with constmgr class e.g.: $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 e.g.: 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 <svetoslav.marinov@gmail.com> 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 http://devquickref.com - 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 http://www.php.net/manual/en/language.variables.variable.php ************************** 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: <? define("TEST","Fuchs"); $Fuchs = "Test"; echo TEST . "<BR>"; echo ${TEST}; ?> output: Fuchs 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! Svetoslav

  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  
 0%
Total:1,355
This week:1
All time:2,862
This week:560Up
User Ratings User Comments (2)
 All time
Utility:75%StarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:779
 
Its worth nothing to explain that an object messing with the ...
11 years ago (Rodrigo Contreras K.)
15%Star
Excellent
14 years ago (kishore kumar)
80%StarStarStarStarStar