为何实例化对象的时候总是既调用了构造函数又调用了析构函数?
class Car { function __construct(){print '父类构造函数被调用 \n';} } class Truck extends Car{ function __construct(){print '子类构造函数被调用';} function __destruct(){print '析构函数被调用 \n'; } } $car = new Car(); $truck = new Truck();
class Car { function __construct(){print '父类构造函数被调用 \n';} } class Truck extends Car{ function __construct(){print '子类构造函数被调用';} function __destruct(){print '析构函数被调用 \n'; } } $car = new Car(); $truck = new Truck();
2018-05-17
举报