本文整理汇总了PHP中B::bar方法的典型用法代码示例。如果您正苦于以下问题:PHP B::bar方法的具体用法?PHP B::bar怎么用?PHP B::bar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类B
的用法示例。
在下文中一共展示了B::bar方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foo
<?php
class A
{
function foo()
{
if (isset($this)) {
echo '$this está definida (';
echo get_class($this);
echo ")\n";
} else {
echo "\$this no está definida.\n";
}
}
}
class B
{
function bar()
{
// Nota: la siguiente línea arrojará una advertencia si E_STRICT está habilitado.
A::foo();
}
}
$a = new A();
$a->foo();
// Nota: la siguiente línea arrojará una advertencia si E_STRICT está habilitado.
A::foo();
$b = new B();
$b->bar();
// Nota: la siguiente línea arrojará una advertencia si E_STRICT está habilitado.
B::bar();
示例2: foo
class A
{
private $a = 0;
protected $b = 0;
public $c = 0;
function foo()
{
var_dump($this->a, $this->b, $this->c);
}
function bar()
{
echo __METHOD__ . "\n";
var_dump($this->a, $this->b, $this->c);
}
}
class B extends A
{
public $a = 1;
public $b = 1;
public $c = 1;
function foo()
{
var_dump($this->a, $this->b, $this->c);
}
}
$x = new A();
$x->foo();
$x = new B();
$x->foo();
$x->bar();
示例3: foo
<?php
class A
{
public function foo()
{
echo "A::foo()\n";
}
}
class B extends A
{
public function __call($f, $args)
{
echo "B::__call({$f}, {$args})\n";
}
}
$o = new B();
// this will call A::foo. The __call is used only when
// nothing was found in the whole hierarchy, not just
// when nothing was found in your class.
$o->foo();
// this will call B::__call
$o->bar();
示例4: foo
function foo()
{
if (isset($this)) {
echo '$this is defined (';
echo get_class($this);
echo ")\n";
} else {
echo "\$this is not defined.\n";
}
}
}
class B
{
function bar()
{
A::foo();
}
}
$a = new A();
$a->foo(); // foo是普通方法,$a绑定到$this,因此,$this is defined(A);
A::foo(); // 这样调用,是不规范的.$this is not defined
$b = new B();
$b->bar(); // bar是普通方法,$b绑定到$this,bar(){A::foo-这里是静态调用,不操作$this}
// $this is defined (B);
B::bar(); // this is not defined
?>
示例5: doBar
public function doBar()
{
$this->bar();
// G G
B::bar();
// B B
C::bar();
// C C
D::bar();
// D D
F::bar();
// F F
G::bar();
// G G
H::bar();
// H H
parent::bar();
// F G
self::bar();
// G G
static::bar();
// G G
echo "****************\n";
}
示例7: bar
print $t['class'] . $t['type'] . $t['function'] . "\n";
}
}
static function bar()
{
debug_print_backtrace();
$bt = debug_backtrace();
foreach ($bt as $t) {
print $t['class'] . $t['type'] . $t['function'] . "\n";
}
}
}
class B extends A
{
function __construct()
{
parent::__construct();
}
function foo()
{
parent::foo();
}
static function bar()
{
parent::bar();
}
}
$b = new B();
$b->foo();
B::bar();