Doc #81620 [Asn->Csd]: parse_ini_file and parse_ini_string don't actually support value interpolation

[email protected] Mon, 15 Nov 2021 12:44:24 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=81620&edit=1

 ID:                 81620
 Updated by:         [email protected]
 Reported by:        php dot net at keven dot fr
 Summary:            parse_ini_file and parse_ini_string don't actually
                     support value interpolation
-Status:             Assigned
+Status:             Closed
 Type:               Documentation Problem
 Package:            PHP options/info functions
 Operating System:   Linux
 PHP Version:        Irrelevant
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/f8b0bb410016270b696b28d3d416672dd2f7e66b
Log: Fix #81620: parse_ini_file and parse_ini_string don't actually support value interpolation


Previous Comments:
------------------------------------------------------------------------
[2021-11-15 12:27:14] [email protected]

> From the documentation, parse_ini_file() and parse_ini_string()
> should support value interpolation:

They do, but only if the variable is a proper PHP configuration
option which has been explicitly defined in php.ini etc. or an
environment variable.

------------------------------------------------------------------------
[2021-11-13 14:33:15] php dot net at keven dot fr

Description:
------------
From the documentation, parse_ini_file() and parse_ini_string() should support value interpolation:

var_dump(parse_ini_string('
foo = bar
baz = ${foo}
'));

should produce:

array(2) {
  ["foo"]=>
  string(3) "bar"
  ["baz"]=>
  string(3) "bar"
}

but it produces this instead:

array(2) {
  ["foo"]=>
  string(3) "bar"
  ["baz"]=>
  string(0) ""
}

See it live: https://3v4l.org/K15ft

On the other hand, env var value interpolation seems to work:

var_dump(parse_ini_string('
path = ${PATH}
'));

result:

array(1) {
  ["path"]=>
  string(13) "/usr/bin:/bin"
}

See it live: https://3v4l.org/cE4dL



Test script:
---------------
var_dump(parse_ini_string('
foo = bar
baz = ${foo}
'));


Expected result:
----------------
array(2) {
  ["foo"]=>
  string(3) "bar"
  ["baz"]=>
  string(3) "bar"
}


Actual result:
--------------
array(2) {
  ["foo"]=>
  string(3) "bar"
  ["baz"]=>
  string(0) ""
}



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81620&edit=1