|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
36 + 31 = ?
Subscribe to this entry?

 [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 08:01:25 2023 UTC