php.net |  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
Description:
------------
Foreach issues warning with link to http://php.net/manual/en/function.main.php when iterating over SimpleXML object.

Test script:
---------------
<?php // oop_bug_main.php
error_reporting(E_ALL);
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>
</category>
XML;
$obj = SimpleXML_Load_string($xml);
$key = 0;
foreach ($obj->item as $item) {
    $attrs = $item->attributes();
    if ($attrs['delete'] == 'true') unset($obj->item[$key]);
    $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 />


Patches

Pull Requests

History

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

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 08 05:01:28 2024 UTC