<?php
/**
* Configuration tool examples
* @package ConfigTool
*/
// Set notices off from error reporting if you want to use simpliest
// and straight method to get configuration variable names.
error_reporting( E_ALL ^ E_NOTICE );
// In development environment you should have:
// error_reporting( E_ALL );
/**
* Include ConfigTool class and make object for the simple example
*/
include( "../ConfigTool.php" );
// make object
$conf = new ConfigTool();
// to get configuration information from the text file
// any relative path can be used BUT absolute path must be used
// if you want to make changes and save new configuration files!
// see advanced_example to learn more
$conf->setConfigFromFile( "example_config_file.txt" );
// now it's up to you...
// print value of the key that you have defined on the configuration file
echo "hello1 = " . $conf->hello1;
// more safely: you can call get() method and give key name as a parameter
// to it and method will return undefined, if variable is not defined in
// conf object. This will prevent possible notice errors in your script.
echo "<br />myvar = " . $conf->get( 'myvar' );
?>
|