相关疑难解决方法(0)

什么是PHP中的函数重载和覆盖?

在PHP中,你的意思是函数重载和函数重写.它们两者有什么区别?无法弄清楚它们之间有什么区别.

php overriding overloading

127
推荐指数
5
解决办法
24万
查看次数

PHP手册OOP可见性示例 - 有人可以解释它

我在PHP OOP手册http://www.php.net/manual/en/language.oop5.visibility.php中看到了这个,我无法理解为什么输出不是:Foo :: testPrivate Foo: :testPublic

class Bar 
{
    public function test() {
        $this->testPrivate();
        $this->testPublic();
    }

    public function testPublic() {
        echo "Bar::testPublic\n";
    }

    private function testPrivate() {
        echo "Bar::testPrivate\n";
    }
}

class Foo extends Bar 
{
    public function testPublic() {
        echo "Foo::testPublic\n";
    }

    private function testPrivate() {
        echo "Foo::testPrivate\n";
    }
}

$myFoo = new foo();
$myFoo->test(); // Bar::testPrivate 
                // Foo::testPublic
Run Code Online (Sandbox Code Playgroud)

php oop

6
推荐指数
1
解决办法
371
查看次数

标签 统计

php ×2

oop ×1

overloading ×1

overriding ×1