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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 + 9 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC