Re: DOMNode children iteration (was Re: array() returns something weird)
| From: | Szczepan Hołyszewski | Date: | Wed, 26 Aug 2009 07:47:49 +0000 |
| Subject: | Re: DOMNode children iteration (was Re: array() returns something weird) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297239@lists.php.net to get a copy of this message | ||
Martin Scotta wrote:
> Fatal error: Call to a member function getAttribute() on a non-object in
> testme.php on line *121*
Yes, this is _how_ the unmodified script errors out. It is not shown in the
output I attached in my previous message because display_errors is Off in my
php.ini, and the line that sets it to On in my script is commented out.
> I'm using a Apache/2.2.3 (Win32) PHP/5.2.6
I am not using Apache at all. The same error can be seen when I run the script
directly through php on the command line.
> Is the script correctly? I have removed the "&" in the loop
I know that iterating a DOMNode's children using firstChild and nextSibling by
reference causes trouble, thank you. The problem is that it causes trouble
with objects unrelated to the loop itself, e.g. to variables defined _after_
the loop has terminated.
> and the script returns the attached file.
Do you mean it returns what is in the output file _I_ have attached, or did
_you_ try to attach something? If that is the case, then your attachment
didn't get through.
> It looks like a bogus bug?
I am certain it _is_ a genuine bug. For example, in PHP when you write:
$foo = array();
echo gettype($foo);
the output should not be NULL, but in my example script (unmodified, with
iteration by reference) things like this start happening at some point.
Regards,
Szczepan Hołyszewski