[ create a new paste ] login | about

Link: http://codepad.org/9DeSMUvu    [ raw code | output | fork ]

PHP, pasted on Jul 28:
<?php

class Foo {
    static $i = 5;
    private $p = 5;

    function bar() {
        echo self::$i . ". ($this->p) Foo->bar() called\n";

        self::$i--;
        $this->p--;

        if (!self::$i) return false;

        return true;
    }
}

function myFoo() {
    return new Foo();
}

while ($foo = myFoo()->bar()) {}

?>


Output:
1
2
3
4
5
5. (5) Foo->bar() called
4. (5) Foo->bar() called
3. (5) Foo->bar() called
2. (5) Foo->bar() called
1. (5) Foo->bar() called


Create a new paste based on this one


Comments: