|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61773 each() are printing null characters for objects
Submitted: 2012-04-19 13:05 UTC Modified: 2012-04-19 20:22 UTC
From: dread dot eklund at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: Irrelevant OS: Linux
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.
Block user comment
Status: Assign to:
Bug Type:
From: dread dot eklund at gmail dot com
New email:
PHP Version: OS:


 [2012-04-19 13:05 UTC] dread dot eklund at gmail dot com
When using the each() function on objects, private and protected variables gets a NUL character around them (see expected result).

Create the test script and view it in a browser (I used Firefox 11.0). 

If you send an email with the output, the mail() function will just truncate the message after the NUL character

Test script:
class Foo
   public $a;
   protected $b;
   private $c;

   function bar($value) {
      echo $value;

$tmp = new Foo();

while(list($key, $value) = each($tmp)) {

Expected result:
string(1) "a"
string(4) "*b"
string(6) "Fooc"

Without the NUL character

Actual result:
string(1) "a"
string(4) "�*�b"
string(6) "�Foo�c"

� = NUL character, ASCII code (dec): 0


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-19 20:22 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

using each() on objects is a legacy feature, the NULL-bytes are part of the internal representation of private and protected elements.
 [2012-04-19 20:22 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jan 22 16:01:24 2021 UTC