blob: 9c9e1716ad42e72783a5a564c52e20a6b2b45618 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<?php
/**
* Stuff for handling configuration files in PHP format.
* @file
* @author Niklas Laxström
* @copyright Copyright © 2010 Niklas Laxström
* @license GPL-2.0+
*/
/**
* Stuff for handling configuration files in PHP format.
*/
class PHPVariableLoader {
/**
* Returns a global variable from PHP file by executing the file.
* @param $_filename \string Path to the file.
* @param $_variable \string Name of the variable.
* @return \mixed The variable contents or null.
*/
public static function loadVariableFromPHPFile( $_filename, $_variable ) {
if ( !file_exists( $_filename ) ) {
return null;
} else {
require $_filename;
return isset( $$_variable ) ? $$_variable : null;
}
}
}
|