本文整理汇总了PHP中B::test方法的典型用法代码示例。如果您正苦于以下问题:PHP B::test方法的具体用法?PHP B::test怎么用?PHP B::test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类B
的用法示例。
在下文中一共展示了B::test方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
$c = new C();
B::test($c);
C::test($c);
D::test($c);
}
示例2: main
function main()
{
$a = new A();
$b = new B();
$c = new C();
B::test($a);
C::test($b);
E::test($c);
}
示例3: testNoForward
public static function testNoForward()
{
A::test();
call_user_func("A::test");
call_user_func(array("A", "test"));
B::test();
call_user_func("B::test");
call_user_func(array("B", "test"));
}
示例4: main
function main()
{
call_user_func(array('A', 'private_func'), "1", "2", "3");
call_user_func(array('A', 'protected_func'), "1", "2", "3");
call_user_func(array('A', 'public_func'), "1", "2", "3");
call_user_func(array('B', 'private_func'), "1", "2", "3");
call_user_func(array('B', 'protected_func'), "1", "2", "3");
call_user_func(array('B', 'public_func'), "1", "2", "3");
A::test();
B::test();
}
示例5: mycatch
public static function mycatch()
{
try {
static::who();
B::throwException_after();
} catch (Exception $e) {
static::who();
A::test();
static::who();
B::test();
static::who();
self::simpleCatch();
static::who();
}
}
示例6: test
<?php
class A
{
protected $fld = 42;
public function test()
{
var_dump($this->fld);
}
}
class B extends A
{
protected $fld = 2;
}
$a = new A();
$b = new B();
$a->test();
$b->test();
示例7: __construction
<?php
class A
{
protected $a;
public function __construction()
{
echo __CLASS__;
}
public function test()
{
$b = new self();
var_dump($this->a);
die;
return $b->a;
}
public function setA($a)
{
$this->a = $a;
}
}
class B extends A
{
public function test1()
{
}
}
$a = new B();
$a->setA(1);
$b = $a->test();
var_dump($b);
示例8: test
static function test()
{
$b = new B();
$b->text = [];
$b->test([1, 2, 3]);
}
示例9: test
<?php
trait TestTrait
{
public static function test()
{
return 'Forwarded ' . forward_static_call(array('A', 'test'));
}
}
class A
{
public static function test()
{
return "Test A";
}
}
class B extends A
{
use TestTrait;
}
echo B::test();
示例10: testprivate
<?php
class A
{
private static function testprivate()
{
return 1;
}
public static function test()
{
return function () {
return self::testprivate();
};
}
}
class B extends A
{
}
$fn = B::test();
echo $fn();
示例11: __sleep
public function __sleep()
{
return $GLOBALS['g'];
}
static function test($a, $elems, $p = null)
{
global $g;
$a->seta(42);
$g = $elems;
$s = serialize($a);
var_export($s);
echo "\n";
$u = unserialize($s);
var_dump($u);
if ($p) {
var_dump($u->{$p});
}
}
}
B::test(new A(), array("a"));
B::test(new A(), array("Aa"));
B::test(new A(), array("*a"));
B::test(new A(), array("*b"), "b");
B::test(new A(), array("Bb"), "b");
B::test(new A(), "foo");
B::test(new B(), array("a"));
B::test(new B(), array("Aa"));
B::test(new B(), array("*a"));
B::test(new B(), array("*b"), "b");
B::test(new B(), array("Bb"), "b");
示例12: test
<?php
class A
{
const NAME = 'A';
public static function test()
{
$args = func_get_args();
echo static::NAME, " " . join(',', $args) . " \n";
}
}
class B extends A
{
const NAME = 'B';
public static function test()
{
echo self::NAME, "\n";
forward_static_call(array('A', 'test'), 'more', 'args');
forward_static_call('test', 'other', 'args');
}
}
B::test('foo');
function test()
{
$args = func_get_args();
echo "C " . join(',', $args) . " \n";
}
示例13: test
<?php
class A
{
public static function test($x = null)
{
if (!is_null($x)) {
echo "{$x}\n";
}
return get_called_class();
}
}
class B extends A
{
}
class C extends A
{
}
class D extends A
{
}
echo A::test(B::test(C::test(D::test()))) . "\n";
?>
==DONE==
示例14: var_dump
var_dump(get_object_vars($b));
}
}
class C extends B
{
private $hiddenPriv = 'C::hiddenPriv';
public static function test($b)
{
echo __METHOD__ . "\n";
var_dump(get_object_vars($b));
}
}
class X
{
public static function test($b)
{
echo __METHOD__ . "\n";
var_dump(get_object_vars($b));
}
}
$b = new B();
echo "\n---( Global scope: )---\n";
var_dump(get_object_vars($b));
echo "\n---( Declaring class: )---\n";
B::test($b);
echo "\n---( Subclass: )---\n";
C::test($b);
echo "\n---( Superclass: )---\n";
A::test($b);
echo "\n---( Unrelated class: )---\n";
X::test($b);
示例15: __construct
}
EventLoop::$instance = new EventLoop();
class A
{
protected $ev;
public function __construct(EventLoop $ev)
{
$this->ev = $ev;
}
public function test()
{
return $this->ev;
}
}
class B
{
public function test()
{
return EventLoop::$instance;
}
}
$aInstance = new A(new EventLoop());
$benchmark->add('without-static-normal-injection', function () use($aInstance) {
return $aInstance->test();
});
$bInstance = new B();
$benchmark->add('with-static-global-state', function () use($bInstance) {
return $bInstance->test();
});
$benchmark->setCount(10000000);
$benchmark->run();