|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63993 foreach issues notice with main() link
Submitted: 2013-01-15 18:04 UTC Modified: 2013-01-16 10:32 UTC
From: ray dot paseur at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.3Git-2013-01-15 (snap) OS: Mac
Private report: No CVE-ID: None
 [2013-01-15 18:04 UTC] ray dot paseur at gmail dot com
Foreach issues warning with link to when iterating over SimpleXML object.

Test script:
<?php // oop_bug_main.php
echo "<pre>";
$xml = <<<XML
<category id='1' title='category 1'>
  <item id='a' title='item a' delete='true' />
  <item id='b' title='item b' delete='false'>B Stays</item>
$obj = SimpleXML_Load_string($xml);
$key = 0;
foreach ($obj->item as $item) {
    $attrs = $item->attributes();
    if ($attrs['delete'] == 'true') unset($obj->item[$key]);

Expected result:
No message about function main()

Actual result:
<pre><br />
<b>Warning</b>:  main() [<a href='function.main'>function.main</a>]: Node no longer exists in <b>/Applications/MAMP/htdocs/oop_bug_main.php</b> on line <b>12</b><br />


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-16 03:07 UTC]
-Status: Open +Status: Not a bug
 [2013-01-16 03:07 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

this main means it's at the top scope...
 [2013-01-16 10:32 UTC] ray dot paseur at gmail dot com
"this main means it's at the top scope..."  

What does that mean, in plain language, please?  The script fails, and it issues a warning message that refers the client to a page that says, "If you discover such a reference, please ยป file a bug report, indicating the PHP function caused the error that linked to main() and it will be fixed and properly documented."

I'd be grateful for your help, thanks.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 23:01:29 2023 UTC