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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: danbeck at dealnews dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-11 14:57 UTC] sander@php.net
Dupe of 3462
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC