|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-01-13 02:33 UTC] 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
)
Patchesbug63980.patch (last revision 2013-01-14 03:44 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
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 }