本文整理汇总了PHP中B::operation方法的典型用法代码示例。如果您正苦于以下问题:PHP B::operation方法的具体用法?PHP B::operation怎么用?PHP B::operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类B
的用法示例。
在下文中一共展示了B::operation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Classname
{
return $input * $input;
}
}
// -- test creating of the instance of ClassName
$a = new Classname("First");
$a = new Classname("Second");
$a = new Classname("Third");
$a->attribute = "value";
echo $a->attribute;
$a->private_attribute = 5;
echo $a->private_attribute;
$a = new A();
$a->operation();
$b = new B();
$b->operation();
// ----------------------------------------------
// reflection - check types and instanceof
// ----------------------------------------------
// high effecient instanceof methods
//
// - note on how to convert a boolean to string
echo "{\$b instanceof B}" . ['false', 'true'][$b instanceof B] . "\n";
echo "{\$b instanceof A}" . ['false', 'true'][$b instanceof A] . "\n";
echo "{\$b instanceof Displayable}" . ['false', 'true'][$b instanceof Displayable] . "\n";
// ----------------------------------------------
// type hint -use of instanceof
// ----------------------------------------------
// - uncomment the statements to uncover the error.
/*function check_hint(B $something) {
示例2: A
public $test1 = 'PHP';
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();