Вопрос

Is there a way to parse an .ini file with the settings callable as objects?

$config = parse_ini_file(ABSPATH . '/config.ini', true);

$dbName = $config->database->name;

//instead of
$dbName = $config['database']['name'];
Это было полезно?

Решение

Try this.

$config = json_decode(json_encode($config));

And now you can use syntax like this.

 $dbName = $config->database->name
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top