开发者

OOP theory question :: $this->someVariable = $someValue

开发者 https://www.devze.com 2023-03-22 07:31 出处:网络
I was wondering what this statement actually does: $this->nameInObject = $someValue; So if you\'re inside a class object that has a variable \"nameInObject\", are you assigning a value of someVa

I was wondering what this statement actually does:

$this->nameInObject = $someValue;

So if you're inside a class object that has a variable "nameInObject", are you assigning a value of someValue to that instance of nameInObject? I开发者_如何学Pythons it only intended to last as long as the session? Does it over ride the initial value of nameInObject?

Thanks


It will override any previous value.

It will only affect the current instance of the object.


Yes, you are assigning the value of someValue to the instance of nameInObject.

Yes, nameInObject will last only the lifetime of the variable this refers to; however, someValue will continue to live on.

Yes, you will override whatever value nameInObject contains with the value someValue contains.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号