pairings =
[[('greg', 'lilly'), ('john', 'samantha'), ('andy', 'tammy')],
[('greg', 'lilly'), ('john', 'tammy'), ('andy', 'samantha')],
[('greg', 'samantha'), ('john', 'lilly'), ('andy', 'tammy')],
[('greg', 'samantha'), ('john', 'tammy'), ('andy', 'lilly')],
[('greg', 'tammy'), ('john', 'lilly'), ('andy', 'samantha')],
[('greg', 'tammy'), ('john', 'samantha'), ('andy', 'lilly')]]
我想在<?php
class mainClass
{
public function demo()
{
return "You have entertered to demo1";
}
}
class childClass extends mainClass
{
public function demo2()
{
return $this->demo();
}
public function demo3()
{
return "You have entered to demo3";
}
}
中调用demo3
的{{1}}方法。因为我是oops的新手,我有点困惑。我也在考虑这个抽象类。但我对抽象类的想法不够。
答案 0 :(得分:0)
这是你在找什么?您不必调用mainClass,因为您通过新的childClass扩展它。我还在demo3中添加了echo以在屏幕上显示结果。
<?php
class mainClass
{
public function demo()
{
return "You have entertered to demo1";
}
}
class childClass extends mainClass
{
public function demo2()
{
return $this->demo();
}
public function demo3()
{
echo "You have entered to demo3";
}
}
$test = new childClass;
$test->demo3();
?>