Edit report at https://bugs.php.net/bug.php?id=63980&edit=1
ID: 63980 User updated by: thbley at gmail dot com Reported by: thbley at gmail dot com Summary: object members get trimmed by zero bytes -Status: Feedback +Status: Open Type: Bug Package: *General Issues Operating System: Win64 -PHP Version: 5.5.0alpha2 +PHP Version: 5.5.0alpha3-nts Block user comment: N Private report: N New Comment: Thanks, var_dump() works. But it would be great if get_object_vars() and foreach() could be fixed. Here is a more detailed test: $arr = ["abc\0def" => "abc\0def"]; $obj = (object)$arr; print_r($arr); // ok echo "\n"; var_dump($obj); // ok echo "\n"; echo serialize($obj); // ok echo "\n"; echo (int)property_exists($obj, "abc"); // ok echo "\n"; echo (int)isset($obj->{"abc"}); // ok echo "\n"; echo json_encode($obj); // ok echo "\n"; var_dump((array)$obj); // ok echo "\n"; var_export($obj); // bug echo "\n"; print_r($obj); // bug echo "\n"; debug_zval_dump($obj); // bug echo "\n"; var_dump(get_object_vars($obj)); // bug echo "\n"; echo get_object_vars($obj)["abc"]; // bug echo "\n"; foreach ($obj as $key=>$val) { echo $key." : ".$val."\n"; // bug } Previous Comments: ------------------------------------------------------------------------ [2013-01-13 12:55:01] larue...@php.net it's due to print_r specific behavior for object's properties... if you use var_dump instead, you will see it's not trimmed. ------------------------------------------------------------------------ [2013-01-13 02:33:33] thbley at gmail dot com Description: ------------ Array keys are not trimmed by zero bytes. (ok) Object member names are trimmed by zero bytes. (bug) Test script: --------------- $arr = ["abc\0def" => "abc\0def"]; print_r($arr); print_r((object)$arr); Expected result: ---------------- Array ( [abc def] => abc def ) stdClass Object ( [abc def] => abc def ) Actual result: -------------- Array ( [abc def] => abc def ) stdClass Object ( [abc] => abc def ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63980&edit=1