Home  >  Article  >  Backend Development  >  使用Yii生成的类与自己new出来有什么区别呢?

使用Yii生成的类与自己new出来有什么区别呢?

WBOY
WBOYOriginal
2016-06-06 20:45:18912browse

比如缩略图类:
$thumb = Yii::app()->thumb;
与 $thumb=new Cthumb()有什么区别?
是对象销毁的时候有区别吗?

回复内容:

比如缩略图类:
$thumb = Yii::app()->thumb;
与 $thumb=new Cthumb()有什么区别?
是对象销毁的时候有区别吗?

前者每次引用的是同一对象。
后者(你自己创建的),你每次创建的对象,都是单独的。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn