php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #5408 foreach() should silently ignore non-array's passed to it
Submitted: 2000-07-06 17:35 UTC Modified: 2001-11-11 14:57 UTC
From: danbeck at dealnews dot com Assigned:
Status: Duplicate Package: Feature/Change Request
PHP Version: 4.0 Latest CVS (06/07/2000) OS: Redhat 6.1 (Linux 2.2.12-20)
Private report: No CVE-ID: None
 [2000-07-06 17:35 UTC] danbeck at dealnews dot com
I feel foreach() should silently ingore any non-array variables passed to it, especially if this was modeled after the same Perl statement.  At the very least, I would like to be able to use the @ notation in front of it so that the script won't die if it doesn't get it's array.  Otherwise, I have to continually use is_array() before using foreach() just to make sure my script continues to live.  Since PHP doesn't make you delcare or initialize variables, you can't always expect that the variables you give a statement or function will be what they are supposed to me.

I know that I can just turn my error reporting down, but I do want to see other valid script and parse errors.

Thanks,

Daniel Beckham

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-11 14:57 UTC] sander@php.net
Dupe of 3462
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC