|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37522 Parse_str do not send back anything
Submitted: 2006-05-19 16:30 UTC Modified: 2006-05-28 01:00 UTC
Avg. Score:4.6 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: No Feedback Package: Strings related
PHP Version: 5.1.4 OS: osx
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-05-19 16:30 UTC]
Parse_str accepts the string, but do not send back anything. 

With one argument, no variable is created. If this is 
register_globals related, we should state it in the docs. 

With 2 arguments, the array is emptied, but not filled.

This bugs is on PHP 5.1.4, 5.1.3 but not 4.4.2.

Reproduce code:
$str = "first=value&arr[]=foo+bar&arr[]=baz";
echo $first;  // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz

parse_str($str, $output);
echo $output['first'];  // value
echo $output['arr'][0]; // foo bar
echo $output['arr'][1]; // baz

$query = 'parametre=valeur'; 

$q = array("1");
parse_str($query, $q);


Expected result:
valuefoo barbazvaluefoo barbazarray(2) {
  string(5) "value"
  array(2) {
    string(7) "foo bar"
    string(3) "baz"
array(1) {
  string(6) "valeur"

Actual result:
PHP Notice:  Undefined variable: first in /Users/imac/
Desktop/test.bug.php on line 15
PHP Notice:  Undefined variable: arr in /Users/imac/Desktop/
test.bug.php on line 16
PHP Notice:  Undefined variable: arr in /Users/imac/Desktop/
test.bug.php on line 17
PHP Notice:  Undefined index:  first in /Users/imac/Desktop/
test.bug.php on line 20
PHP Notice:  Undefined index:  arr in /Users/imac/Desktop/
test.bug.php on line 21
PHP Notice:  Undefined index:  arr in /Users/imac/Desktop/
test.bug.php on line 22
array(0) {
PHP Notice:  Undefined variable: parametre in /Users/imac/
Desktop/test.bug.php on line 29
PHP Notice:  Undefined variable: parametre2 in /Users/imac/
Desktop/test.bug.php on line 30
PHP Notice:  Undefined variable: tableau in /Users/imac/
Desktop/test.bug.php on line 31
array(0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 17:33 UTC]
I can't reproduce on Linux with 5.1 nor with 5.2
 [2006-05-19 18:22 UTC]
register_globals fixed the problem for the first part 
(parse_str with 1 argument). This means the doc should reflect 

parse_str with 2 arguments still holds...
 [2006-05-19 18:23 UTC]
OK, this bug is related to  #24208.
It actually fails the test (from make test).
 [2006-05-20 14:03 UTC]
Works perfectly fine here.
I get the expected result with 5.1.4, 5.2.0-CVS and 4.4.3-CVS.
 [2006-05-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 18:01:29 2024 UTC