php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81620 parse_ini_file and parse_ini_string don't actually support value interpolation
Submitted: 2021-11-13 14:33 UTC Modified: 2021-11-15 12:27 UTC
From: php dot net at keven dot fr Assigned: cmb (profile)
Status: Closed Package: PHP options/info functions
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 46 = ?
Subscribe to this entry?

 
 [2021-11-13 14:33 UTC] 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) ""
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-15 12:27 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: PHP options/info functions -Assigned To: +Assigned To: cmb
 [2021-11-15 12:27 UTC] cmb@php.net
> 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-15 12:44 UTC] git@php.net
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
 [2021-11-15 12:44 UTC] git@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 23:01:31 2024 UTC