Exemple #1
0
 function f()
 {
     $y = new Y();
     $y->foo();
     static::g();
     $y->foo();
     self::g();
     Y::foo() && static::g();
 }
Exemple #2
0
function test()
{
    $a = X::foo();
    $a();
    $a = Y::foo();
    $a();
    $a = X::bar();
    $a();
    $a = Y::bar();
    $a();
    $x = new X();
    $a = $x->bar();
    $a();
    $x = new Y();
    $a = $x->bar();
    $a();
    $a = X::bar_nonstatic();
    $a();
    $a = Y::bar_nonstatic();
    $a();
    $x = new X();
    $a = $x->bar_nonstatic();
    $a();
    $x = new Y();
    $a = $x->bar_nonstatic();
    $a();
}
Exemple #3
0
<?php

class W
{
    const FOO = 0;
}
class X extends W
{
    const FOO = 1;
    static function foo()
    {
        var_dump(constant('self::FOO'));
        var_dump(constant('parent::FOO'));
        var_dump(constant('static::FOO'));
        var_dump(defined('self::FOO'));
        var_dump(defined('parent::FOO'));
        var_dump(defined('static::FOO'));
        var_dump(defined('self::BAR'));
        var_dump(defined('parent::BAR'));
        var_dump(defined('static::BAR'));
    }
}
class Y extends X
{
    const FOO = 2;
    const BAR = 1;
}
X::foo();
Y::foo();