php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41592 print_r() truncates attribute / property names containing NULL
Submitted: 2007-06-04 22:59 UTC Modified: 2014-11-02 00:50 UTC
From: php at digitalbacon dot us Assigned: requinix (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.3 OS: Windows XP (recent)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at digitalbacon dot us
New email:
PHP Version: OS:

 

 [2007-06-04 22:59 UTC] php at digitalbacon dot us
Description:
------------
If you have a property name containing a NULL character, some PHP routines like print_r() will truncate the name, most likely due to C-string processing limitations.

I know PHP syntax doesn't permit NULL characters within attribute names, however, it's easily done when the name is contained in a variable. The only limitation seems to be that an attribute cannot start with NULL. Since it's "allowed," then PHP should fully support its effects.

Reproduce code:
---------------
<?php
$c = new stdClass;
$a = "HIDDEN\000-TEXT";
$c->$a = 'foo';
print_r($c);
?>

Expected result:
----------------
stdClass Object ( ["HIDDEN\000-TEXT"] => foo )

Actual result:
--------------
stdClass Object ( [HIDDEN] => foo )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-02 00:50 UTC] requinix@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: requinix
 [2014-11-02 00:50 UTC] requinix@php.net
Fixed in 5.5.
http://3v4l.org/rc678
http://3v4l.org/rEFe1
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 16:08:09 2025 UTC