|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45890 Memory exhausted while trying to iterate simplexml object property
Submitted: 2008-08-22 07:58 UTC Modified: 2008-08-22 14:09 UTC
From: vans9 at yandex dot ru Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.6 OS: FreeBSD 6.2
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: vans9 at yandex dot ru
New email:
PHP Version: OS:


 [2008-08-22 07:58 UTC] vans9 at yandex dot ru
While trying to iterate SimpleXML's object property (array) with next(), memory exhausted.

Reproduce code:
$classes=new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\"?>
for ($classEntry=current($classes->class); $classEntry!==false; $classEntry=next($classes->class))
	echo "\n";
echo 'Done smth.';

Expected result:
Expected: <class> elements of <classes> xml entry being printed.

Actual result:
Lot's of output and than "Allowed memory size of 134217728 bytes exhausted (tried to allocate 16 bytes)". Output may be ommited, but problem persists.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-22 08:06 UTC] vans9 at yandex dot ru
And if you look at the output, printing the <class> entries is expected, but class-sub-entries are printed with current, and next.
 [2008-08-22 14:09 UTC]
The $classes->class isn't an array.

Warning: current() expects parameter 1 to be array, object given
Warning: next() expects parameter 1 to be array, object given 

foreach ($classes->class as $class) {

And see the examples at:

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Sep 24 06:01:24 2023 UTC