php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16684 parse error on foreach given array as $_REQUEST['list']
Submitted: 2002-04-18 12:17 UTC Modified: 2002-04-18 12:53 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: bob at mroczka dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.0 OS: linux
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: bob at mroczka dot com
New email:
PHP Version: OS:

 

 [2002-04-18 12:17 UTC] bob at mroczka dot com
i would like to iterate over the array named $_REQUEST['list'] like this:

foreach($_REQUEST['list'] as $user) {
	if (strlen($user")>$max) die("too long");
}
error_log("gettype gives: ". gettype($_REQUEST['list']),0);

when php attempts to run this code I get this parse error in my apache log:

PHP Parse error:  parse error, unexpected '\"' in /var/www/htdocs/tmp.php on line 698

The message I write to the log about the type confirms that the variable is an array.

I am currently using 4.2.0rc4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-18 12:37 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php


 [2002-04-18 12:45 UTC] bob at mroczka dot com
This is not a support question.  I know there many ways
to iterate over an array.  I just wanted to alert you to the fact
there is a problem with the foreach construct in its
handling of multi-dimensional arrays.
 [2002-04-18 12:48 UTC] robert at webmotion dot com
> foreach($_REQUEST['list'] as $user) {
>         if (strlen($user")>$max) die("too long");
                          ^
                         ^^^
                        ^^^^^
                          I
                          I
                          I
                          I

Cheers,
Rob.
 [2002-04-18 12:53 UTC] sander@php.net
user error -> bogus
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 10:01:24 2019 UTC