php / doc-en

English PHP documentation
508 stars 740 forks source link

Comments in parse_ini_file #2510

Open lesilent opened 1 year ago

lesilent commented 1 year ago

I stumbled upon this "feature" concerning how parse_ini_file (and parse_ini_string) handles comments. For the longest time I thought comments started with a semi-colon, After all, that's how it's done in php.ini and the sample in Example # 1 for parse_ini_file states: ; Comments start with ';', as in php.ini

But recently I noticed that Example # 5 has an in-line comment: quoted = "She said \"Exactly my point\"." ; Results in a string with quote marks in it.

So I tested that, and much to my surprise, inline-comments are indeed supported by parse_ini_file and parse_ini_string. It might be helpful to make that a bit more clear and/or update the line in example # 1 stating that comments typically start with a semi-colon (but not always).

cmb69 commented 4 months ago

Well, comments always start with a semicolon, but the semicolon doesn't have to be the first character of a line. That basically works like one-line PHP comments. The php.ini example on https://www.php.net/manual/en/configuration.file.php already explains that, so I'm not sure whether we need to clarify this for parse_ini_*().