返回自动加载案例,......登陆

自动加载案例,访问

弃。2019-03-12 19:02:40332

<?php 


class Company{


public $name;//公共的;


protected $position;//受保护的,可以再子类调用


private $salary;//私有的,只能在类内调用;



public function __construct($name,$position,$salary)

{

$this->name=$name;

$this->position=$position;

$this->salary=$salary;

}

public function GetPosition(){

return $this->position;

}

public function GetSalary(){

$res = $this->salary;

if ($this->name == '杨俊杰') {

echo '这个人太厉害了,你这个渣渣不配查看他的工资';

}else{

return $res;

}

}

}

<?php 


spl_autoload_register(function($className){

require __DIR__.'\public\\'.$className.'.php';

});




$Company = new Company('杨俊杰','总经理',50000);


// echo '我是受保护的属性值----》'.$Company->GetPosition();//调用受保护的属性


// echo $Company->GetSalary();调用私有的属性







 ?>

YZ7ZDUJA6U]YVD@RX0$_%MB.png

最新手记推荐

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

全部回复(0)我要回复

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