php - Return Current Object Through Static method -


I want to return the current object of a square. As $ $ this variable refers to the current object of that class, but when I return it, I get an error.

This is my code

  class test {$ name; Public static function getobj ($ n) {$ this- & gt; Name; $ This return; }} $ Obj = Test :: getobj ("doc");  

You do not use $ this inside a code You can make an example of the class and then have to return it:

  class test {public $ name; Public static function getobj ($ n) {$ o = new self; $ O- & gt; Name = $ n; $ O flame; }} $ Obj = Test :: getobj ("doc"); // $ obj- & gt; Name == "doc"  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -