Kin
Kin

Reputation: 4596

Is it possible to check custom ini file syntax in PHP?

I have a custom ini file with configurations (does not refer to php ini file) and i need to check it's syntax. Found a function parse_ini_file which parses the file, but it generates warning if file is bad, may be there is some function to check if before parse?

Upvotes: 2

Views: 1529

Answers (1)

Matteo Tassinari
Matteo Tassinari

Reputation: 18584

As anticipated in my comment, I would go this way:

function valid_ini_file($path) {
  return @parse_ini_file($path) !== false;
}

clear and concise.

Upvotes: 3

Related Questions