class Editor { var $Error = '' ; var $Pages; function vol() { $Pages = array(); $this->Pages[] = new page; } }
class Page { var $Id = ''; var $BackImage; function vol() { $BackImage = array(); // $this->$BackImage[] = new Decorator; //Fatal error: Cannot use [] for reading $this->BackImage[] = new Decorator; //只能这样写,因为 $BackImage 是数组 } }
class Decorator { var $Ext = ''; }
$Editor = new Editor; $Editor->vol(); $Editor->Pages[0]->vol();
$Editor->Pages[0]->BackImage[0]->Ext = 'str' ; $Editor->Pages[2]->BackImage[2]->Ext = 'str2'; //Warning: Creating default object from empty value
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论