Is a “static” keyword required in PHP?

It seems that the uaa () function can be used as a static function, even if it is not specifically defined as such. I am wondering if the "static" keyword should be used.

<?php

class foo
{
    functon uaa()
    {
        // do something
    }
}
+3
source share
2 answers

I'm not sure. But if you do this, it starts E_STRICT:

Strict standards: the non-static method a :: non_static () should not be called statically in c: \ file.php on line 12

It is probably wise to talk about what is static and what is not, at least you are unlikely to do something like trying to access an $thisout-of-context object.

+10
source

, . E_STRICT. $this , ( , E_WARNING, ).

static . . , , .

, " " . , PHP "", ( E_STRICT).

+4
source

Source: https://habr.com/ru/post/1757647/


All Articles