/ Published in: PHP
URL: http://www.mechanicmatt.com/toDo/
This is just something I came up with for this new project I'm doing. It's an OOP way to have a configuration file and share it amongst several other things.
Further down is how you would share it in another application. Your class/script now has the OOP values of the config. Further more, you can code additional methods within your settings class to call which would dynamically modify your config even further. Possibilities are endless :P
Expand |
Embed | Plain Text
<?php require_once("../settings.php"); class sharedConfig { public $host = ""; public $db = ""; public $un = ""; public $pw = ""; public $absolute = "http://www.mechanicmatt.com/toDo/"; public $relative = "/toDo/"; public $now = ""; public $path = ""; public $skinDir = "skins/"; public $skin = 0; public function __construct() { /* this is where you would run any processing code to add/edit/delete any additional configuration values programmatically. For example... This config script includes my database connection values (host, username, password) from yet another shared config script. */ global $sqlServer; $this->host = $sqlServer["host"]; $this->db = "mford_toDo"; $this->un = $sqlServer["un"]; $this->pw = $sqlServer["pw"]; } } ?> //script using/sharing this file <?php class yourClass { private $config = stdClass; public function __construct() { include("sharedConfig.php"); $this->config = new sharedConfig(); } } ?>
You need to login to post a comment.
