Issues

ZF-7772: iterating over a Zend_Config

Description

There are two xml-files.


<?xml version="1.0" encoding="utf-8" ?>

and


<?xml version="1.0" encoding="utf-8" ?>

and the sample code:


<?php
    require_once 'Zend/Config.php';
    require_once 'Zend/Config/Xml.php';
    
    $config = new Zend_config_xml('/path/to/config.xml');
    foreach ($config->files->file as $value)
        echo 'id: '.$value->id.'
location: '. htmlspecialchars($value->location).''; ?>

If the {{/path/to/config.xml}} to substitute {{config1.xml}}, then everything works correctly. But if you substitute {{config2.xml}} error


Notice: Trying to get property of non-object in D:\www\index.php on line 7

How can I iterate all items {{file}}, if their number is not known in advance (one or more than one)?

Comments

This issue is related to ZF-6109, but I create this clone issue because the original is set only for ZF version 1.7.7, but ZF version 1.9.2 still has the issue

See related issue for more comments on this issue

{quote} How can I iterate all items file, if their number is not known in advance (one or more than one)? {quote}

The more important question is how do we solve this without breaking backwards compatibility?

Duplicate of ZF-6109