【发布时间】:2017-02-04 08:05:36
【问题描述】:
如何动态调用该方法? 我已经调用了函数:
public function type_bien($value)
{
$stype['1'] = "Maison";
$stype['2'] = "Appartement";
$stype['4'] = "Appartement meublé";
$stype['7'] = "Propriété";
return $stype[$value];
}
<?php echo type_bien($row['type_bien']); ?>
-> Returns: Deprecated: Non-static method Utils::type_bien() should not be called statically
【问题讨论】:
-
你正在返回一些东西,所以你应该像这样调用函数:
<?php $myResult = type_bien($row['type_bien']); echo $myResult; ?> -
您能否更具体地说明为什么将其声明为公共函数而不将其包装在类中?它是函数还是类方法?
-
Emn1ty-> 这其实是一个类:
-
class Utils { public function type_bien($value) { $stype['1'] = "Maison"; $stype['2'] = "公寓"; $stype['4'] = "公寓meublé"; $stype['7'] = "专有été";返回 $stype[$value]; } }
-
当我打电话时: