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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 14:01:30 2025 UTC