\Config_File

Config file reading class

Summary

Methods
Properties
Constants
Config_File()
set_path()
get()
get_key()
get_file_names()
get_section_names()
get_var_names()
clear()
load_file()
set_file_contents()
parse_contents()
_set_config_var()
_trigger_error_msg()
$overwrite
$booleanize
$read_hidden
$fix_newlines
$_config_path
$_config_data
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$overwrite

$overwrite : 

Controls whether variables with the same name overwrite each other.

Type

$booleanize

$booleanize : 

Controls whether config values of on/true/yes and off/false/no get converted to boolean values automatically.

Type

$read_hidden

$read_hidden : 

Controls whether hidden config sections/vars are read from the file.

Type

$fix_newlines

$fix_newlines : 

Controls whether or not to fix mac or dos formatted newlines.

If set to true, \r or \r\n will be changed to \n.

Type

$_config_path

$_config_path : 

Type

$_config_data

$_config_data : 

Type

Methods

Config_File()

Config_File(string  $config_path = NULL) 

Constructs a new config file class.

Parameters

string $config_path

(optional) path to the config files

set_path()

set_path(string  $config_path) 

Set the path where configuration files can be found.

Parameters

string $config_path

path to the config files

get()

get(string  $file_name, string  $section_name = NULL, string  $var_name = NULL) : string|array

Retrieves config info based on the file, section, and variable name.

Parameters

string $file_name

config file to get info for

string $section_name

(optional) section to get info for

string $var_name

(optional) variable to get info for

Returns

string|array —

a value or array of values

get_key()

get_key(  $config_key) : string|array

Retrieves config info based on the key.

Parameters

$config_key

Returns

string|array —

same as get()

get_file_names()

get_file_names() : array

Get all loaded config file names.

Returns

array —

an array of loaded config file names

get_section_names()

get_section_names(string  $file_name) : array

Get all section names from a loaded file.

Parameters

string $file_name

config file to get section names from

Returns

array —

an array of section names from the specified file

get_var_names()

get_var_names(string  $file_name,   $section = NULL) : array

Get all global or section variable names.

Parameters

string $file_name

config file to get info for

$section

Returns

array —

an array of variables names from the specified file/section

clear()

clear(string  $file_name = NULL) 

Clear loaded config data for a certain file or all files.

Parameters

string $file_name

file to clear config data for

load_file()

load_file(string  $file_name, boolean  $prepend_path = true) 

Load a configuration file manually.

Parameters

string $file_name

file name to load

boolean $prepend_path

whether current config path should be prepended to the filename

set_file_contents()

set_file_contents(string  $config_file, string  $contents) 

Store the contents of a file manually.

Parameters

string $config_file

file name of the related contents

string $contents

the file-contents to parse

parse_contents()

parse_contents(string  $contents) 

parse the source of a configuration file manually.

Parameters

string $contents

the file-contents to parse

_set_config_var()

_set_config_var(  $container, string  $var_name, mixed  $var_value, boolean  $booleanize) 

Parameters

$container
string $var_name
mixed $var_value
boolean $booleanize

determines whether $var_value is converted to to true/false

_trigger_error_msg()

_trigger_error_msg(string  $error_msg, integer  $error_type = E_USER_WARNING) 

Parameters

string $error_msg
integer $error_type

one of