005-对象——对象的 final const
<?php /** * */ /*class shouji { public $pinpai; final function chongdian() { //final 最终的 return $this->pinpai."手机通过10v电压充电"; } function kaijidonghua(){ return "<<< 开机动画 >>>"; } } class moto extends shouji { function __construct() { $this->pinpai = "摩托罗拉"; } function kaijidonghua(){ return "摩托罗拉的商标"; } } class sanxing extends shouji { function __construct() { $this->pinpai = "三星"; } function kaijidonghua(){ return "三星的商标"; } } //$moto = new moto(); //echo $moto->chongdian(); class ren { private $mingzi; function __construct($ming) { $this->mingzi = $ming; } function yongshouji($shouji) { $shouji = new $shouji(); echo $this->mingzi."的手机开机动画是:".$shouji->kaijidonghua()."<br/>"; echo $this->mingzi . "在用" . $shouji->pinpai . " " . $shouji->chongdian(); } } $lisi = new ren("李四"); $lisi->yongshouji("moto");*/ /*final class bangong { private $diannao;//电脑 private $chuanzhenji;//传真机 private $saomiaoyi;//扫描仪 function __construct($diannao,$chuanzhenji,$saomiaoyi) { $this->diannao=$diannao; $this->chuanzhenji=$chuanzhenji; $this->saomiaoyi=$saomiaoyi; } function sheji() { return $this->diannao . "来设计"; } function saomiao() { return $this->saomiaoyi . "来扫描"; } } $bangong=new bangong('戴尔',"三星传真机","爱克发"); echo $bangong->sheji(); echo "<br/>================<br/>"; echo $bangong->saomiao(); echo "<br/>================<br/>";*/ //const /*define('webname','蓝天网'); echo webname;*/ define('WEBNAME',"蓝天"); class caiwu { const suilv = 0.05; //类常量: function __construct() { echo WEBNAME; } function kaigongzi($xingming, $gongzi) { $gongzi = $gongzi - $gongzi * self::suilv; return $xingming . "的工资是" . $gongzi . "元"; } } /*员工类*/ class yuangong { private $xingming;//姓名 private $gongzisu;//工资数 function __construct($xingming, $gongzisu) { $this->xingming = $xingming; $this->gongzisu = $gongzisu; } function kaizi() { $caiwu = new caiwu(); return $caiwu->kaigongzi($this->xingming, $this->gongzisu); } } $lisi = new yuangong('李四', "6000"); echo $lisi->kaizi();