YANA 4 PHP Framework
Docs for page config.php
Handling of Config- and SML-Files
Name | Type | Description |
---|---|---|
$input | string | |
$mode | int |
This function is pretty much the same as getConfigFile() except for the fact that it is working on strings rather than files.
Returns NULL on error.
The argument $input has to be a string, that has been encoded using makeConfig().
The argument $mode can be used to decide how keys should be treated.
Valid values for $mode are:
Note: to reaccess an encoded value look at the following examples.
Handling boolean values:
- $input_bool = true;
- $encoded = makeConfig($input_bool, 'MY_VAR');
- $decoded = decodeConfigString($encoded);
- // the following returns true
- $input_bool === $decoded['MY_VAR'];
... or shorter:
- $input_bool = true
- // the following returns true
- $input_bool === array_pop(decodeConfigString(makeConfig($input_bool)));
Handling string values and nummerics:
- $input_string = 'foo';
- // the following returns true
- $input_string === array_pop(decodeConfigString(makeConfig($input_string)));
- $input_int = 123;
- // the following returns true
- $input_int == array_pop(decodeConfigString(makeConfig($input_int)));
Handling the 'NULL' value:
- $input_null = null;
- // the following returns true
- is_null( array_pop(decodeConfigString(makeConfig($input_string))) );
Arrays (were key case does matter):
- $input_array = array(1,2,3,array(4,5),'a'=>6,'B'=>7);
- $output_array = decodeConfigString(makeConfig($input_array,null,CASE_MIXED),CASE_MIXED);
- // the following returns true
- $input_array == $output_array;
When dealing with nummeric arrays, or associative arrays where all keys are uppercase, or if you just don't care, there is also an ...
... even shorter way to do it:
- $input_array = array(1,2,3,array(4,5),'A'=>6,'B'=>7);
- $output_array = decodeConfigString(makeConfig($input_array));
- // the following returns true
- $input_array == $output_array;
Name | Type | Description |
---|---|---|
$input | array|string | |
$mode | int |
The argument $input can wether be a filename or a numeric array of strings created by file($filename).
The argument $mode can be used to decide how keys should be treated.
Valid values for $mode are:
Name | Type | Description |
---|---|---|
$filename | string | |
$mode | int |
The argument $mode can be used to decide how keys should be treated.
Valid values for $mode are:
Name | Type | Description |
---|---|---|
$filename | string | |
$mode | int |
The argument $name can be used to specify the name of the root node. If $name is omitted, no root node is created.
Note that this function will issue an E_USER_NOTICE if $name is omitted and $data is a scalar value. In this case the scalar variable will be named '0' by default.
The argument $mode can be used to decide how keys should be treated.
Note that any tags from string inputs will be stripped. You should convert tags to entities, before submiting the input.
Valid values for $mode are:
Documentation generated on Fri, 10 Nov 2006 00:35:53 +0100 by phpDocumentor 1.3.0RC4