Re: foreach() broken
| From: | (Marcus B�rger) | Date: | Sun, 14 Sep 2003 11:10:26 +0000 |
| Subject: | Re: foreach() broken | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4475@lists.php.net to get a copy of this message | ||
Hello Sebastian,
Sunday, September 14, 2003, 12:15:43 PM, you wrote:
> Sebastian Bergmann wrote:
>> I was not able to strip the application I'm seeing this in down to a
>> small, reproducing snippet, yet.
> Okay, here goes:
> <?php
> class Foo {
> function doFoo() {
> print_r($this);
> }
> }
> class Bar {
> function doBar() {
> Foo::doFoo();
> }
> }
> $bar = new Bar;
> $bar->doBar();
> ?>
> bar Object
> (
> )
> I know that this code's logic is wrong (after the latest refactoring of
> the previously mentioned application I had a leftover (no unit tests,
> yet *sigh*) where a method was previously static).
> But still. Is this the correct behaviour?
No it's wrong. your calling a non static method without an object here. So
we need to find out where the error is.
> And why does
> class Foo {
> static function doFoo() {
> print_r($this);
> }
> }
> give a
> Notice: Undefined variable: this
> instead of the appropriate $this / object context warning?
Absolute correct: static = no $this
--
Best regards,
Marcus mailto:helly@php.net