返回类的封装,公开......登陆

类的封装,公开,私有,继承

cole2019-04-30 16:22:54279

<?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();


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送