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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php dot net at keven dot fr
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 23:01:28 2025 UTC