开发者

What's the difference between this two PHP object instantiation types?

开发者 https://www.devze.com 2023-03-20 19:21 出处:网络
I wonder about the differences of this PHP instantiation type. $object = new MyClass(); 开发者_开发技巧

I wonder about the differences of this PHP instantiation type.

$object = new MyClass();

开发者_开发技巧

vs

$this->object = new MyClass();

What's the difference between this two?


The first one instantiates an object of MyClass to a variable object in variable-scope.

The second one instantiates an object of MyClass in another(not necessarily a different one) class object attributes value.

0

精彩评论

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