Created
November 9, 2014 11:25
-
-
Save adarwash/c55bb3318c49f7ef87b2 to your computer and use it in GitHub Desktop.
Added ability to read the configuration values in the initialisation file and added comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Config { | |
//$path is the value that going to be pass thought for exmaple "Config::get('mysql/host')" the part 'mysql/host' will be the path. | |
public static function get($path = null){ | |
if($path) { | |
//$config make it easier to write $GLOBALS['config']; | |
$config = $GLOBALS['config']; | |
// Explode will read each value in parts using the forward slash for example mysql/host mysql is first part and host is the seconned part. | |
$path = explode('/', $path); | |
// For every value in $path will be store in a variable called $bit | |
foreach($path as $bit){ | |
//This will check if the value is set in the initialisation file (init.php); | |
if(isset($config[$bit])){ | |
// After the checked if the value isset then it will store value in variable called $config | |
$config = $config[$bit]; | |
} | |
} | |
//This will return the value that is set. | |
return $config; | |
} | |
// If there no value set then i will return false | |
return false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment