php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11604 count() error codes
Submitted: 2001-06-21 11:17 UTC Modified: 2001-06-22 18:17 UTC
From: vroemisse at home dot nl Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.5 OS: Linux/any
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: vroemisse at home dot nl
New email:
PHP Version: OS:

 

 [2001-06-21 11:17 UTC] vroemisse at home dot nl
count($var) can return 0 if $var is not set and 1 if $var is not an array. 

In my view these overlap with proper return values - I can have an empty array and I can have an array with only 1 element. Actually, I often do.

Please make count($var) return -1 and -2 in these cases so I can reliably determine what's the situation with $var.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-22 18:17 UTC] hholzgra@php.net
you should use is_array() for argument type checking
*before* calling count() or sizeof()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 20:01:29 2024 UTC