Re: Error trapping config class
| From: | Bertrand Mansion | Date: | Wed, 07 Mar 2007 09:05:57 +0000 |
| Subject: | Re: Error trapping config class | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26752@lists.php.net to get a copy of this message | ||
Le 7 mars 07 à 01:56, Leonie Price a écrit :
I have an ini file containing a number of items: my.ini.php: $gs_config['person'] = '2007-02-02 22:57:00'; $gs_config['order'] = '2007-02-02 22:57:00'; I have also created a simple class to manipulate this ini file: require_once("Config.php"); class gs_config { var $ini_file = "my.ini.php"; var $config=null; var $options = array('name' => 'gs_config'); var $root=null; function gs_config() {Don't call getContent() if item is null.$this->config = new Config();} function read() {if (!$this->root) { $this->root =& $this->config->parseConfig($this->ini_file,"PHPArray", $this->options);}} function extract($key) {$this->read(); $item = $this->root->getItem('directive', $key); return $item->getContent();