Re: parse_ini_file VS. constructor with many parameters

From: Date: Wed, 07 Jul 2004 08:47:25 +0000
Subject: Re: parse_ini_file VS. constructor with many parameters
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189852@lists.php.net to get a copy of this message
John W. Holmes wrote:
I'd prefer the text file. It's easier to open that and change values plus they don't have to worry about PHP syntax as much. Haven't tried, but you should be able to import them as private variables for your class...
Thanks for the advice John. OK, so extending this a bit: all of the objects are singletons. Would it be better to have one ini file per class, or combine class settings into one "master" ini file? By the way, if any else is interested you *can* import these values as private variables. Probably the easiest way might be like this: <?php class usesIniFile { private $_iniFile = 'path/to/file.ini'; private $_secretProps = array(); function __construct($args) {
    // do stuff with $args
    $this->_secretProps = parse_ini_file();
} } ?>

« previous php.general (#189852) next »