|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
48 - 2 = ?
Subscribe to this entry?

 [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-2020 The PHP Group
All rights reserved.
Last updated: Thu Dec 03 01:01:23 2020 UTC