2012-07-23 145 views
1

我有一个Model.class.php和一个Bag.class.php,Bag类扩展了Model类。php方法undefined error

但是当我尝试调用Bag.class.php定义的函数,它表明“在调用未定义功能fill_entity()”一个致命的错误

bag.class.php:

class Bag extends Model{ 
public function __construct($table_name){ 
    $this->table_name = $table_name; 
} 

public function fill_entity($row){ 
    $this->id = $row['bagID']; 
    $this->name = $row['bagName']; 
    $this->price = $row['bagPrice']; 
    $this->url = $row['bagURL']; 
    $this->img_url = $row['bagImgURL']; 
    $this->mall_id = $row['mallID']; 
    $this->brand_id = $row['brandID']; 
} 

这里是我的PHP网页,我调用这个函数:

$bag = new Bag($bagtype); 
$bag.fill_entity($row); <---- error on this line. 
+3

使用' - >'替代'''来引用函数。 – 2012-07-23 02:39:04

+0

哦,狗屎。多谢你们。 – MrROY 2012-07-23 02:45:01

+2

...因为你写的是有效的PHP。它尝试连接一个不存在的全局函数'fill_entity()'和变量'$ bag'的输出。 – 2012-07-23 02:45:31

回答

2

在PHP中,这将是$bag->fill_entity($row);而非$bag.fill_entity($row);