私はこの質問をする方法を知らないので、タイトルがそうではありません。誰もができれば良い..私はそれがFoo::testPrivate
とFoo::testPublic
を印刷しますと思っどのよう$myFoo->test()
プリントBar::testPrivate
とFoo::testPublic
上記のコードでphp oop visibility:親クラスの関数がそれ自身の私的関数と子クラスの公開関数を呼び出す方法
¶
<?php
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
?>
を変更してください