Bug #61773 [Opn->Nab]: each() are printing null characters for objects
Edit report at https://bugs.php.net/bug.php?id=61773&edit=1
ID: 61773
Updated by: johannes@php.net
Reported by: dread dot eklund at gmail dot com
Summary: each() are printing null characters for objects
-Status: Open
+Status: Not a bug
Type: Bug
Package: Arrays related
Operating System: Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
using each() on objects is a legacy feature, the NULL-bytes are part of the internal representation
of private and protected elements.
Previous Comments:
------------------------------------------------------------------------
[2012-04-19 13:05:41] dread dot eklund at gmail dot com
Description:
------------
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)) {
var_dump($key);
}
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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61773&edit=1
Thread (2 messages)