Location: PHPKode > scripts > Constant Management class > constant-management-class/constmgr.class.php
<?php

	/**
	this class is used to define constants and update their values on the fly

	@package: constmgr
	@author: Svetoslav Marinov <hide@address.com>
	@see: http://www.php.net/manual/en/language.variables.variable.php

*/

class constmgr
{
	/**
	*	class constructor
	*	@param none
	*	@return void
	*/
	function & constmgr()
	{
	}

	/**
	*	a constant setter - defines a constant
	*	@param string $const_name
	*	@param string $const_value
	*	@return void
	*/
	function set( $const_name, $const_value = '' )
	{
		//$const_name = strtoupper( $const_name );
		$const_name_unique = __CLASS__ . "_" . md5( $const_name );
		global $$const_name_unique;

		// check if already defined ?
		if ( !isset( $$const_name_unique ) )
			@define( $const_name, $const_name_unique );

		$$const_name_unique = $const_value;

		/*print "const_name:".$const_name . "\n";
		print "const_value:".$const_value . "\n";
		print "const_name_unique:".$const_name_unique . "\n";*/
	}

	/**
	*	a constant getter
	*	@param string $const_name
	*	@return mixed
	*/
	function get( $const_name )
	{
		//$const_name = strtoupper( $const_name );
		$const_name_unique = __CLASS__ . "_" . md5( $const_name );
		global $$const_name_unique;

		// check if already defined ?
		if ( isset( $$const_name_unique ) )
			return ${ $const_name_unique };
	}
}


?>
Return current item: Constant Management class