When to use self over $this?

前端 未结 23 2864
醉梦人生
醉梦人生 2020-11-21 11:19

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

When is each appropriate?

23条回答
  •  故里飘歌
    2020-11-21 12:05

    Here is an example of correct usage of $this and self for non-static and static member variables:

    non_static_member . ' '
               . self::$static_member;
        }
    }
    
    new X();
    ?> 
    

提交回复
热议问题