0

I recently got to know a new use of static keyword.

I can also refer to the current class using static keyword.

So, say I have below class.

class X {

         static $x = 'Hello World!';

         public function greet(){

              return static::$x; //Or self::$x           
              }
         }

As, I can access $x both ways using static::$x and self::$x.

So, Is there any difference betwen them? I can use them interchangeably or There is some cases they behave differently?

sujeet
  • 3,480
  • 3
  • 28
  • 60
  • 1
    I serached before asking, but couldn't find any link, maybe keywords issue. Anyway thanks for the link, those answers are great and helped me a lot. – sujeet Jun 29 '19 at 13:40
  • Searching can be incredibly frustrating. It's super hard to find an answer to a question, if you don't know how to ask the question. Web searching is definitely a skill; one I need to hone myself. – Reed Jun 29 '19 at 14:34

0 Answers0