| Why we need use is_array on object constructor |
| by Oki on 2003/10/24 10:56:26 Hi, I have a big question. I have studied the code of XOOPS Classes, but i can't understand why we need to use the function is_array() if always the variable is replaced by the next array item. I look in all code for an answer, but i can't find. Is it a bug trap? le="color: #000000"><?php class.newsstory.php function NewsStory($storyid=-1) { $this->db =& Database::getInstance(); $this->table = $this->db->prefix("stories"); $this->topicstable = $this->db->prefix("topics"); if (is_array($storyid)) { $this->makeStory($storyid); $this->newstopic = $this->topic(); } elseif($storyid != -1) { $this->getStory(intval($storyid)); $this->newstopic = $this->topic(); } } On makeStory method in class XoopsStory we aren't get new instances of XoopsStory (...) le="color: #000000"><?php function makeStory($array) { foreach ( $array as $key=>$value ){ $this->$key = $value; } } Best regards, Celso Goya moinho.net |