本文整理汇总了PHP中C::operation方法的典型用法代码示例。如果您正苦于以下问题:PHP C::operation方法的具体用法?PHP C::operation怎么用?PHP C::operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C
的用法示例。
在下文中一共展示了C::operation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: B
echo "类的继承<br/>";
$b = new B();
//$b -> operation2(); Fatal error: Call to protected method A::operation2() from context ''
$b->say_something();
$b->lila = 10;
$b->do_something();
$b->lilb = 10;
class C
{
public $attribute = "default value";
function operation()
{
echo "Something<br/>";
echo "The value of \$attribute is " . $this->attribute . "<br/>";
}
}
class D
{
public $attribute = "different value";
function operation()
{
echo "Something else<br/>";
echo "The value of \$attribute is " . $this->attribute . "<br/>";
}
}
echo "方法与属性的重载<br/>";
$c = new C();
$c->operation();
$d = new D();
$d->operation();
//parent::operation();
示例2: A
public $test2 = 'Java';
public $test3 = 'C++';
}
$a = new A();
foreach ($a as $output) {
echo $output . '<br />';
}
//类的继承关系
class B
{
public $test = "very large";
function operation()
{
echo "welcome.<br /><br />";
echo "The value of \$test is {$this->test}. <br /><br />";
}
}
class C extends B
{
public $test = "perfect";
function operation()
{
echo "welcome back <br /><br />";
echo "The value of \$test is {$this->test} <br /><br />";
}
}
$a = new B();
$a->operation();
$b = new C();
$b->operation();