|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-07-11 19:12 UTC] kurt dot newman at cpanel dot net
Description: ------------ --- From manual page: http://www.php.net/function.parse-ini-string --- This impacts PHP versions: 5.4.45, 5.5.37, 5.6.23, and 7.0.8. The documentation does not say that ini entries will be missing and should be considered a bug. The documentation says: parse_ini_string() returns the settings in string ini in an associative array. As such, this function doesn't properly parse a PHP ini string AND return the complete settings described in said string within a resulting associative array. Test script: --------------- <?php # How to duplicate # echo -e "extension = foo.so\nextension = bar.so\n" > foo.ini # cat foo.ini | ./thisscript.php $ini = ""; $stdin = fopen('php://stdin', 'r'); while (($line = fgets($stdin)) != false) $ini .= $line; fclose($stdin); if (!($arr = parse_ini_string($ini, true, INI_SCANNER_RAW))) { fwrite(STDERR, "ERROR: Invalid php ini format\n"); exit(1); } print_r( $arr ); exit(0); ?> Expected result: ---------------- Recognize that the 'extension' and 'zend_extension' ini entries are special, and can be duplicated within an ini file. Perhaps consider placing them in some special place so that this information isn't lost. This is just an example, and not a request to use this specific output: Array ( [extension] => Array ( [extension0] => foo.so [extension1] => bar.so ) ) Actual result: -------------- # Observe that "foo.so" was defined in the example noted in # the 'Test script', but is missing in the actual usage. Array ( [extension] => bar.so ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
Your repro script is far more complicated than it needs to be... print_r(parse_ini_string("extension = foo.so\nextension = bar.so")); php.ini is the weird one here, using duplicate names for loading extensions. Highly unusual for an INI file - but its reason for doing so makes sense. parse_ini_string is handling the duplicates the same way that nearly every other INI scanner out there does: overwrite. So really what you're asking for is an option to allow duplicates, right? To put multiple values into an array (wouldn't be that name+counter format) without having to use the [] syntax.