From your question & later comments I think that you could be wanting to read an ini file from within two php scripts. There is nothing stopping you doing this, it would be possible to read the file from within both scripts, but we do not want to repeat the code in each script.
So I would suggest you need three scripts, something along these lines:
database.php // the original which is currently reading from config.ini
config.php // the new script which you also want to read the config.ini
readconfig.php // does the reading of the ini
The readconfig.php
should have a public function that does something like:
public function ReadDbSettings($inifile, $host, $user, $password)
{
// do the mechanics of reading the ini, use your existing code which is working
// set the supplied parameters which values from the ini
$host = $ini_array['HOST'];
...
return TRUE; // the settings were read
}
In terms of the actual mechanics of reading the ini one option is to use parse_ini_file to read in the contents into an array. A contrived example:
$ini_array = parse_ini_file("my.ini");
if (empty($ini_array['IniSetting']))
{
$this->variable = 'defaultvalue';
}
else
{
$this->variable = $ini_array['IniSetting'];
}