|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42413 Cannot iterate IE's event object
Submitted: 2007-08-24 12:06 UTC Modified: 2020-02-06 16:31 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: csaba at alum dot mit dot edu Assigned: cmb (profile)
Status: Not a bug Package: COM related
PHP Version: 5.2.3 OS: Win XP Pro
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:
46 - 39 = ?
Subscribe to this entry?

 [2007-08-24 12:06 UTC] csaba at alum dot mit dot edu
I can't iterate over IE's $ie->document->createEventObject() with PHP whereas I can in IE.

Reproduce code:
// create a new internet explorer instance
$ie = new COM("InternetExplorer.Application");

// So the alerts can be seen
$ie->visible = true;

// ensure a document exists within ie
$ie->Navigate2 ("about:blank");
while ($ie->readyState!=4) usleep(100000);
// convenience
$doc = $ie->document;
$window = $doc->parentWindow;

// required - var must be declared
$window->execScript ("var evt='';");
// create an event object
$window->evt = $doc->createEventObject();

// proof the object is valid, iteratable
  var str=''; var idx;
  for (idx in evt)
    str+=idx+'; ';
  alert('Keys: '+str);");

// Bug: can't iterate the object in PHP
foreach ($window->evt as $prop => $val)
  print "<br>$prop ";

// ensure ie is still alive
$ie->quit();   // necessary since visible

Expected result:
I expect PHP not to die at the foreach
I expect the same text to be output as with the alert

Actual result:
PHP falls over upon hitting the foreach loop with:

Fatal error: Uncaught exception 'Exception' with message 'Object of type variant  did not create an Iterator' in c:\phpBugs\foreach.php: 28
Stack trace:
#0 C:\phpBugs\foreach.php(28): unknown()
#1 {main} thrown in C:\phpBugs\foreach.php on line 28


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-24 12:17 UTC]
Assigned to the maintainer.
 [2014-12-30 05:51 UTC]
-Status: Assigned +Status: Open -Assigned To: wharmby +Assigned To:
 [2020-02-06 16:31 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-02-06 16:31 UTC]
In JavaScript you can iterate over the public properties of any
object. In PHP this works only if the object's isn't Traversable;
however, COM objects are.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 16:05:54 2022 UTC