本文整理汇总了PHP中B::test2方法的典型用法代码示例。如果您正苦于以下问题:PHP B::test2方法的具体用法?PHP B::test2怎么用?PHP B::test2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类B
的用法示例。
在下文中一共展示了B::test2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
function test()
{
A::test1(1, 'a');
B::test2(1, 'a');
self::test3(1, 'a');
parent::test4(1, 'a');
}
示例2: test1
<?php
class A
{
function test1(&$farg1)
{
$farg1 = 1.5;
}
}
class B
{
static function test2(int &$farg2)
{
}
}
function test3(&$farg3)
{
}
$a = new A();
$arg1 = [1, 2, 3];
$a->test1($arg1);
B::test2($arg1);
// No errors from undefined vars since they are by-ref
test3($arg3);
preg_match("/(a)/", "a", $match);
示例3: test3
public static function test3()
{
echo self::NAME, "\n";
forward_static_call(array('A', 'test'));
}
}
class C extends B
{
const NAME = 'C';
public static function test()
{
echo self::NAME, "\n";
forward_static_call(array('A', 'test'));
}
}
A::test();
echo "-\n";
B::test();
echo "-\n";
B::test2();
echo "-\n";
B::test3();
echo "-\n";
C::test();
echo "-\n";
C::test2();
echo "-\n";
C::test3();
?>
===DONE===
示例4: test
<?php
class A
{
private $_attr1 = 123;
protected $_attr2 = 456;
public $attr3 = 789;
public static $attr4 = 'abc';
public function test()
{
echo $this->_attr1, "\n";
echo $this->_attr2, "\n";
}
}
class B extends A
{
public function test2()
{
echo $this->_attr1, "\n";
echo $this->_attr2, "\n";
}
}
$a = new A();
$b = new B();
$a->test();
echo $a->attr3, "\n";
$b->test2();
echo $b->attr3, "\n";
A::$attr4 = 'def';
echo B::$attr4, "\n";