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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Dec 21 17:01:58 2024 UTC