• support@answerspoint.com

When to use self vs $this in PHP Object Programming ?

1937

In PHP 5, what is the difference between using self and $this?

When is each appropriate?

  • PHP

  • asked 8 years ago
  • G John

1Answer


0

From http://www.phpbuilder.com/board/showthread.php?t=10354489:

Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.

  • answered 8 years ago
  • G John

Your Answer

    Facebook Share        
       
  • asked 8 years ago
  • viewed 1937 times
  • active 8 years ago

Best Rated Questions