|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55230 Wrong return value for getAttribute
Submitted: 2011-07-18 08:07 UTC Modified: 2011-07-18 08:33 UTC
From: evoloshchuk at gmail dot com Assigned: salathe (profile)
Status: Closed Package: XML Reader
PHP Version: 5.3.6 OS: Mac OS X 10.6.3
Private report: No CVE-ID: None
 [2011-07-18 08:07 UTC] evoloshchuk at gmail dot com
According to the spec at

Return Values
The value of the attribute, or an empty string if no attribute with the given name is found or not positioned of element.

The actual return value in case if no attribute found is NULL, instead of empty string.

Test script:
$reader = new XmlReader();
$reader->xml('<?xml version="1.0" encoding="UTF-8"?><a></a>');

Expected result:
string(0) ""

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-18 08:13 UTC]
-Type: Bug +Type: Documentation Problem
 [2011-07-18 08:13 UTC]
The documentation is wrong.

An attribute can have an empty string as value, so an empty string cannot be 
used to indicate that the requested attribute does not exist.

NULL is used for this purpose, as described in the XmlReader MSDN 
documentations, which is the specs for the php's xmlreader and writer (see Actually we should maybe 
return NULL for empty value as well. But that could break some code out there.
 [2011-07-18 08:31 UTC]
Automatic comment from SVN on behalf of salathe
Log: changelog for xmlreader::getattribute (doc #55230)
 [2011-07-18 08:32 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2011-07-18 08:32 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2011-07-18 08:33 UTC]
Apologies for the incorrect automated response. The correct one should have been:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 20:01:31 2024 UTC