Difference between self and this keyword in PHP

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
phpkiller
New php-forum User
New php-forum User
Posts: 35
Joined: Thu Jun 28, 2012 2:11 pm

Sun Dec 08, 2013 11:36 pm

As we are using OOPS concepts here are the difference:-

-self refers to the current class
-self can be used to call static functions and reference static
member variables
-self can be used inside static functions
-self 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. Use self instead.
-$this can not be used inside static functions

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest