reference/filesystem/functions/parse-ini-file.xml
a5346daf2bb2fab250fa03f0f6639a408d0b2240
...
...
@@ -203,8 +203,7 @@ function yesno($expression)
203
203
return($expression ? 'Yes' : 'No');
204
204
}
205
205

206
-
// Get the path to php.ini using the php_ini_loaded_file()
207
-
// function available as of PHP 5.2.4
206
+
// Get the path to php.ini using the php_ini_loaded_file() function
208
207
$ini_path = php_ini_loaded_file();
209
208

210
209
// Parse php.ini
...
...
@@ -228,10 +227,10 @@ echo '(loaded) magic_quotes_gpc = ' . yesno(get_cfg_var('magic_quotes_gpc')) . P
228
227
</para>
229
228
<para>
230
229
<example>
231
-
<title>value interpolation</title>
230
+
<title>Value Interpolation</title>
232
231
<para>
233
232
In addition to evaluating constants, certain characters have special meaning in an ini value.
234
-
Additionally, environment variables and previously defined values may be read using
233
+
Additionally, environment variables and previously defined configuration options (see <function>get_cfg_var</function>) may be read using
235
234
<code>${}</code> syntax.
236
235
</para>
237
236
<programlisting>
...
...
@@ -251,22 +250,67 @@ negative_two = ~1
251
250
; () is used for grouping
252
251
seven = (8|7)&(6|5)
253
252

254
-
; \ is used to escape a value.
255
-
newline_is = "\\n" ; results in the string "\n", not a newline character.
256
-
with quotes = "She said \"Exactly my point\"." ; Results in a string with quote marks in it.
257
-

253
+
; Interpolate the PATH environment variable
258
254
path = ${PATH}
259
-
also_five = ${five}
255
+

256
+
; Interpolate the configuration option 'memory_limit'
257
+
configured_memory_limit = ${memory_limit}
260
258

261
259
]]>
262
260
</programlisting>
263
-
&example.outputs.similar;
264
-
<screen>
261
+
</example>
262
+
</para>
263
+
<para>
264
+
<example>
265
+
<title>Escaping Characters</title>
266
+
<para>
267
+
Some characters have special meaning in double-quoted strings and must be escaped by the backslash prefix.
268
+
First of all, these are the double quote <code>"</code> as the boundary marker, and the backslash <code>\</code> itself
269
+
(if followed by one of the special characters):
270
+
</para>
271
+
<programlisting>
265
272
<![CDATA[
266
-
(parsed) magic_quotes_gpc = Yes
267
-
(loaded) magic_quotes_gpc = Yes
273
+
quoted = "She said \"Exactly my point\"." ; Results in a string with quote marks in it.
274
+
hint = "Use \\\" to escape double quote" ; Results in: Use \" to escape double quote
268
275
]]>
269
-
</screen>
276
+
</programlisting>
277
+
<para>
278
+
There is an exception made for Windows-like paths: it's possible to not escape trailing backslash
279
+
if the quoted string is directly followed by a linebreak:
280
+
</para>
281
+
<programlisting>
282
+
<![CDATA[
283
+
save_path = "C:\Temp\"
284
+
]]>
285
+
</programlisting>
286
+
<para>
287
+
If one does need to escape double quote followed by linebreak in a multiline value,
288
+
it's possible to use value concatenation in the following way
289
+
(there is one double-quoted string directly followed by another one):
290
+
</para>
291
+
<programlisting>
292
+
<![CDATA[
293
+
long_text = "Lorem \"ipsum\"""
294
+
dolor" ; Results in: Lorem "ipsum"\n dolor
295
+
]]>
296
+
</programlisting>
297
+
<para>
298
+
Another character with special meaning is <code>$</code> (the dollar sign).
299
+
It must be escaped if followed by the open curly brace:
300
+
</para>
301
+
<programlisting>
302
+
<![CDATA[
303
+
code = "\${test}"
304
+
]]>
305
+
</programlisting>
306
+
<para>
307
+
Escaping characters is not supported in the <constant>INI_SCANNER_RAW</constant> mode
308
+
(in this mode all characters are processed "as is").
309
+
</para>
310
+
<para>
311
+
Note that the ini parser doesn't support standard escape sequences (<code>\n</code>, <code>\t</code>, etc.).
312
+
If necessary, post-process the result of <function>parse_ini_file</function> with <function>stripcslashes</function> function.
313
+
</para>
270
314
</example>
271
315
</para>
272
316
</refsect1>
...
...
@@ -296,7 +340,7 @@ also_five = ${five}
296
340
Values <literal>null</literal>, <literal>off</literal>, <literal>no</literal> and
297
341
<literal>false</literal> result in <literal>""</literal>, and values
298
342
<literal>on</literal>, <literal>yes</literal> and <literal>true</literal> result
299
-
in <literal>"1"</literal>, unless <constant>INI_SCANNER_TYPED</constant> mode is used (as of PHP 5.6.1).
343
+
in <literal>"1"</literal>, unless <constant>INI_SCANNER_TYPED</constant> mode is used.
300
344
Characters <literal>?{}|&amp;~!()^"</literal> must not be used anywhere in
301
345
the key and have a special meaning in the value.
302
346
</simpara>
303
347