1

With the new static keyword in PHP 5, is there any reason to use self keyword? I don't see any use-cases for it anymore

thelolcat
  • 10,995
  • 21
  • 60
  • 102
  • Well, actually there's a difference - have a look here http://stackoverflow.com/questions/151969/php-self-vs-this#answer-6807615 – scibuff Feb 26 '12 at 21:59

3 Answers3

3

self and static mean two different things. See the documentation on late static binding. The first two examples demonstrate the difference.

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
2

In the context of static method if you wish to call another static method - you use self::anotherStaticMethod()

zerkms
  • 249,484
  • 69
  • 436
  • 539
0

It is for static class members (access staic things in the same class) - that do not have a $this.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127