php方法未定义错误
我有一个Model.class.php和一个Bag.class.php,Bag类扩展了Model类 但当我试图调用Bag.class.php中定义的函数时,它显示了一个致命错误“调用未定义的函数fill_entity()” bag.class.php:php方法未定义错误,php,Php,我有一个Model.class.php和一个Bag.class.php,Bag类扩展了Model类 但当我试图调用Bag.class.php中定义的函数时,它显示了一个致命错误“调用未定义的函数fill_entity()” bag.class.php: class Bag extends Model{ public function __construct($table_name){ $this->table_name = $table_name; } public fun
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.
$bag=新包($bagtype);
$bag.fill_实体($row) 在PHP中,它将是$bag->fill_entity($row)代码>而不是$bag.fill\u实体($row)代码>在PHP中,它将是$bag->fill\u entity($row)代码>而不是$bag.fill\u实体($row)代码>您使用了错误的语法。PHP不使用点符号,而是使用
尝试使用以下方法:
$bag->fill_entity($row);
(PHP中仍然使用
,但用于。)
不要为错过这一点感到难过,当我第一次处理PHP时,我已经做了很多次了。您使用了错误的语法。PHP不使用点符号,而是使用
尝试使用以下方法:
$bag->fill_entity($row);
(PHP中仍然使用
,但用于。)
不要为错过这一点感到难过,我在第一次处理PHP时做了很多次。使用->
而不是
来引用函数……因为您编写的是有效的PHP。它试图用变量$bag
连接不存在的全局函数fill_entity()
的输出。使用->
而不是
来引用函数……因为您编写的是有效的PHP。它试图将不存在的全局函数fill_entity()
的输出与变量$bag
连接起来。