为什么模型类构造函数将空值用作参数?

时间:2019-07-19 10:58:25

标签: php constructor

当我看到此reference

中的代码时

当我必须从构造函数中删除null值时,出现一个错误,即在控制器中实例化模型类时未定义构造函数。

public function __construct($name = null,$city = null,$country = null)
{
    $this->name = $name;
    $this->city = $city;
    $this->country = $country;
}

您能否在模型类构造函数中不使用null参数的情况下提供解决方案?

0 个答案:

没有答案
相关问题