Get $this In A Static

<?php

class X {
    function foo() {
        print_r($this);
    }

    function bar() {
        self::foo();
    }

}
?>

A static method does not have access to the current object, by definition.

It is also possible to call statically any method within a class.

But when a static method calls a non-static method, an error is produced: Non-static method x::foo() cannot be called statically.

Finally, calling statically a non-static method still defines $this in the target method. Static is the nature of the method, not the call.

See Also

PHP Error Messages

PHP Features

Last updated: 14 July 2026