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
 [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: Thu Mar 28 15:01:29 2024 UTC