Janusz Lewandowski wrote:
<?php
class A
{
        function mA()
        {
                $this->nA();
        }

        static function mB()
        {
                self::nB();
        }
}

class B extends A
{
        function mA()
        {
                parent::mA();
        }

        static function mB()
        {
                parent::mB();
        }

        function nA()
        {
                echo 'A';
        }

        function nB()
        {
                echo 'B';
        }
}

$obj = new B();
$obj->mA();
B::mB();
?>

Most people will think, that it will output AB. But currently in PHP
5.2 (I don't have PHP 5.3 to test it) it will output:
A
Fatal error: Call to undefined method A::nb() in
Z:\localhost\testLSB.php on line 11

User that sees this, doesn't have any idea where is the problem and
how to find some information about it.


If I may throw my 2 cents in, if it's even worth anything anyway. This is exactly what I would expect the output to be.

If you would want A::mB() to go back to B::nB() I would switch the self::nB() to static::nB(), and have an abstract nB() method declared in A. Is this not how everyone thinks it should be?

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to