php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45012 parse_ini_file() does not correctly bitwise XOR constants
Submitted: 2008-05-15 17:53 UTC Modified: 2008-05-15 22:58 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mjijackson at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.6 OS: Win32
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: mjijackson at gmail dot com
New email:
PHP Version: OS:

 

 [2008-05-15 17:53 UTC] mjijackson at gmail dot com
Description:
------------
parse_ini_file() correctly uses the | and & bitwise operators on constants. However, it does not correctly interpret the ^ (XOR) operator. Instead, it interprets the entire statement as a string.

Reproduce code:
---------------
*** test.ini ***

or = E_ERROR | E_PARSE
xor = E_ALL ^ E_NOTICE

*** PHP ***

$ini = parse_ini_file('test.ini');

echo $ini['or'] . ' ' . (E_ERROR | E_PARSE);
echo "\n";
echo $ini['xor'] . ' ' . (E_ALL ^ E_NOTICE);

Expected result:
----------------
5 5
6135 6135

Actual result:
--------------
5 5
E_ALL ^ E_NOTICE 6135

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-15 18:42 UTC] mjijackson at gmail dot com
Changed OS from Windows XP SP2 to more general Win32
 [2008-05-15 21:50 UTC] felipe@php.net
The php.ini says:

; Expressions in the INI file are limited to bitwise operators and parentheses:
; |        bitwise OR
; &        bitwise AND
; ~        bitwise NOT
; !        boolean NOT

This is valid also to files parsed by parse_ini_file() function.
 [2008-05-15 22:58 UTC] mjijackson at gmail dot com
I see. But shouldn't it include all of PHP's bitwise operators (http://us.php.net/language.operators.bitwise)? The fact that it only parses a subset is confusing and should probably be documented on parse_ini_file()'s documentation page.

Or, perhaps the php.ini comment could be changed from:

"Expressions in the INI file are limited to bitwise operators"

(implying all bitwise operators) to

"Expressions in the INI file are limited to the following bitwise operators"

That seems a bit clearer to me. Thanks for your quick response.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 15:01:27 2024 UTC