class a {
    public $a = "yay!";
    func call_b()
    {
        b::b();
    }
}
class b {
    function b()
    {
        echo $this->a;
    }
} 
$a= new a();
$a->call_b();
Prints:
yay!
This is because if you statically call a method that is not declared as static in PHP, it inherits the class scope of the caller.  Note that if you had declared function b as a static method, you'd get a different behavior.
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment