Correction status:qualified
Teacher's comments:
<?php namespace vehicle\Civic; class Civic { public $name = 'Civic'; private $power = '177'; public function __construct($name, $power) { $this->name = $name; $this->power = $power; } public function race($time='7') { echo '加速时间' . $time . 's'; } }
点击 "运行实例" 按钮查看在线实例
<?php namespace vehicle\Fit; require('Civic.php'); use vehicle\Civic\Civic as Civic; class Fit extends Civic { public $name = 'Fit'; private $power = '131'; public function __construct($name, $power) { $this->name = $name; $this->power = $power; $this->race('9'); } } $newFit = new Fit('new Fit', '131'); echo '<hr/>'; echo $newFit->race('9');
点击 "运行实例" 按钮查看在线实例