Doc #68895 [Nab]: Error on parse_str() example
| From: | nazarenolorenzo at gmail dot com | Date: | Fri, 23 Jan 2015 21:06:56 +0000 |
| Subject: | Doc #68895 [Nab]: Error on parse_str() example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11880@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68895&edit=1
ID: 68895
User updated by: nazarenolorenzo at gmail dot com
Reported by: nazarenolorenzo at gmail dot com
Summary: Error on parse_str() example
Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
You're right. I was confused about how it works.
Thanks for the clarification
Previous Comments:
------------------------------------------------------------------------
[2015-01-23 19:20:58] aharvey@php.net
It's (unfortunately) correct: if the second argument isn't given to parse_str(), it
creates variables in the current scope.
------------------------------------------------------------------------
[2015-01-23 19:16:57] nazarenolorenzo at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.parse-str
---
The first part of the current example prints $arr, which is never declared:
<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first; // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz
Expected result:
----------------
Instead, it should be:
<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
$arr = parse_str($str);
echo $first; // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68895&edit=1