abstract:<?phpclass Staff{ public $name; protected $dept; private $salary; public function __construct($name,$dept,$salary) { $this->name = $name; $this->dept = $dept; $this->salary = $salary; }
<?php
class Staff
{
public $name;
protected $dept;
private $salary;
public function __construct($name,$dept,$salary)
{
$this->name = $name;
$this->dept = $dept;
$this->salary = $salary;
}
public function getDept()
{
return $this->dept;
}
}
$staff = new Staff('小龙女','开发部门','5000');
echo '姓名',$staff->name,'<br>';
echo '部门',$staff->getDept();
Correcting teacher:查无此人Correction time:2019-05-05 09:53:11
Teacher's summary:完成的不错。把php类这章课学完,就相当于入门了。继续加油。