php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71123 parse_str('.a=1&.b=2', $arr); returns wrong result
Submitted: 2015-12-15 02:15 UTC Modified: 2015-12-15 02:43 UTC
From: ptcong90 at gmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.6.16 OS: OS X
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ptcong90 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-15 02:15 UTC] ptcong90 at gmail dot com
Description:
------------
parse_str returns a wrong result if param start with dot (.)

parse_str('.a=1&.b=2', $arr); 

This issue happend in whole versions of php.

Test script:
---------------
parse_str('.a=1&.b=2', $array);

Expected result:
----------------
Array
(
    [.a] => 1
    [.b] => 2
)


Actual result:
--------------
Array
(
    [_a] => 1
    [_b] => 2
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-15 02:43 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: PHP Language Specification +Package: Strings related
 [2015-12-15 02:43 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PHP converts periods to underscores when parsing query strings and form data intentionally. This is documented behavior.
http://php.net/manual/en/language.variables.external.php
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 04:01:23 2019 UTC