php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51899 Parse error in parse_ini_file() function when empy value followed by no newline
Submitted: 2010-05-24 15:36 UTC Modified: 2010-05-26 04:18 UTC
From: aigors at inbox dot lv Assigned: felipe
Status: Closed Package: Filesystem function related
PHP Version: 5.3.2 OS: Windows XP
Private report: No CVE-ID:
 [2010-05-24 15:36 UTC] aigors at inbox dot lv
Description:
------------
The function parse_ini_file raises "PHP Warning:  syntax error, unexpected $end" when ini file has empty last value assignment with no new line after it:

parse_ini_file.ini
a=4
b=

(no new line after the 2nd line).

Test script:
---------------
$data = parse_ini_file('parse_ini_file.ini');
print_r($data);

Expected result:
----------------
Array
(
    [a] => 4
    [b] =>
)

Actual result:
--------------
PHP Warning:  syntax error, unexpected $end in parse_ini_file.ini on line 2
 in C:\work\parse_ini_file.php on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 04:18 UTC] felipe@php.net
-Summary: Parse error in parse_ini_file function +Summary: Parse error in parse_ini_file() function when empy value followed by no newline -Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-05-26 04:18 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-05-26 04:18 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=299767
Log: - Fixed bug #51899 (Parse error in parse_ini_file() function when empy value followed by no newline)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 04:01:57 2014 UTC