When we declare a function as static then we generally get confused about what to use like '->', '::', 'this' or 'self'.
There are something we need to take care of when declaring a function as static:
1: If the variable or method being referenced is declared as const or static, then you must use the :: operator.
2: If the variable or method being referenced is not declared as const or static, then you must use the -> operator.
3: If you are accessing a const or static variable or method from within a class, then you must use the self-reference self.
4: If you are accessing a variable or method from within a class that is not const or static, then you must use the self-referencing variable $this.
0 Comment(s)