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

require_once( "constmgr.class.php" );

// don't define constant value let the class defines its for you
// so it can be managed later
//define( "DRAGON", "first DRAGON value-WRONG!" );

$obj =& new constmgr();

$obj->set( "DRAGON", "DRAGON value" );

print "Defined const (wrongly accessed):" . DRAGON . "\n";
print "New value:" . ${DRAGON} . "\n"; // always use this style to access the new value
print "Get: " . $obj->get( "DRAGON" ). "\n\n";

$obj->set( "DRAGON", "DRAGON value2" );
print "Defined const (wrongly accessed):".DRAGON. "\n";
print "New value:" . ${DRAGON}. "\n"; // always use this style to access the new value
print "Get: " . $obj->get( "DRAGON" ). "\n\n";


/*

Output:

Defined const (wrongly accessed):constmgr_1168a740956462d41d2176f76725f003
New value:DRAGON value
Get: DRAGON value

Defined const (wrongly accessed):constmgr_1168a740956462d41d2176f76725f003
New value:DRAGON value2
Get: DRAGON value2

*/

?>
Return current item: Constant Management class