In PHP 5, what is the difference between using self
and $this
?
When is each appropriate?
From this blog post:
self
refers to the current classself
can be used to call static functions and reference static member variablesself
can be used inside static functionsself
can also turn off polymorphic behavior by bypassing the vtable$this
refers to the current object$this
can be used to call static functions$this
should not be used to call static member variables. Useself
instead.$this
can not be used inside static functions