The documentation on parse_ini_file states that you can't use these chars {}|&~![()^"
in the value. Is there some way to escape these chars? I need to use them. Normal escaping with \ doesn't seem to work.
In PHP, an escape sequence starts with a backslash \ . Escape sequences apply to double-quoted strings. A single-quoted string only uses the escape sequences for a single quote or a backslash.
Character Escaping Because PHP interprets and interpolates special characters inside double-quoted string literals and heredoc string literals, the backslash sign ( \ ) is used as an "escape character". For example, using \$name instead of $name prevents PHP from interpolating the $name variable.
To specify a literal backslash, double it ( \\ ). All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n , will be output literally as specified rather than having any special meaning.
Learn More. In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters: "\t" is a tab, "\n" is a newline, and "\r" is a carriage return.
The manual says those characters can not be used in the key -- the opposite of the value. To use them in values, double-quote the string.
Try using INI_SCANNER_RAW
(from the same documentation) for scanner_mode
:
parse_ini_file ( $filename, true, INI_SCANNER_RAW );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With