php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54153 strlen(array) behavior change as of 5.3
Submitted: 2011-03-03 20:52 UTC Modified: 2011-03-21 18:27 UTC
From: ghensley at gmail dot com Assigned: philip (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3SVN-2011-03-03 (SVN) OS: redhat
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: ghensley at gmail dot com
New email:
PHP Version: OS:

 

 [2011-03-03 20:52 UTC] ghensley at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.strlen#Description
---
I found a "bug" when upgrading from php 5.2.9.

In 5.2.9 stelen when invoked on an array would return the size of the array
In 5.3.3 strlen when invoked on an array returns null

This behavior was sort of unexpected. The documentation might want to reflect the change - or the function should maybe throw a warning or error.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-03 21:18 UTC] philip@php.net
-Summary: Strlen when called on an array ini php 5.3 +Summary: strlen(array) behavior change as of 5.3 -Status: Open +Status: Verified
 [2011-03-03 21:18 UTC] philip@php.net
Confirmed, sort of. 

PHP versions prior to 5.3 will always return 5, because the string 'Array' has a 
length of 5 (it also emits an E_NOTICE error). As of 5.3, it returns NULL and 
emits an E_WARNING error.
 [2011-03-21 18:25 UTC] philip@php.net
Automatic comment from SVN on behalf of philip
Revision: http://svn.php.net/viewvc/?view=revision&revision=309499
Log: Documented strlen() behaviour with arrays including the 5.3 change. Closes PHP Bug #54153
 [2011-03-21 18:27 UTC] philip@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: philip
 [2011-03-21 18:27 UTC] philip@php.net
This is fixed in SVN and will show up online this upcoming Friday. Thank you for 
the bug report :)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 02:00:01 2026 UTC