php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65442 Example number 1 code needs fixing.
Submitted: 2013-08-13 14:01 UTC Modified: 2013-12-18 21:02 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: contactme at antonydandrea dot com Assigned: philstu (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID: None
 [2013-08-13 14:01 UTC] contactme at antonydandrea dot com
Description:
------------
---
From manual page: http://www.php.net/example.xml-structure
---
Example one that shows an example usage throws an undefined index. This is because when it first calls startElement, $depth[$parser] does not get initialised.
To fix this, I changed the startElement function to 
function startElement($parser, $name, $attrs)
{
    global $depth;
    if (isset($depth[$parser])) {
        for ($i = 0; $i < $depth[$parser]; $i++) {
            echo "  ";
        }
    } else {
        $depth[$parser] = 0;
    }
    echo "$name\n";
    $depth[$parser]++;
}
Would be good to add this improvement to the documentation.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-16 21:38 UTC] philstu@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: philstu
 [2013-12-16 21:38 UTC] philstu@php.net
Fixed locally, just waiting on SVN server issues to be resolved before I can commit.
 [2013-12-18 21:02 UTC] philstu@php.net
-Status: Verified +Status: Closed
 [2013-12-18 21:02 UTC] philstu@php.net
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.


 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of philstu
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=8ea1f0e33d8d92be915a4f60eb2477cfbc400601
Log: Fixed bug #65442
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 04:00:01 2026 UTC