今天在项目中遇到了这种情况,在实例化对象时需要向构造函数传递参数,之前不知道能不能、也不知道怎么传。给大家分享一下:
class test1 {
public function __construct($account,$serviceName) {
print_r($account);
}
}
class test extends test1 {
public function __construct($account) {
parent::__construct($account,’ReportService’);
}
}
$service = new test($account);