您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 榆林分类信息网,免费分类信息发布

php抽象类的例子 学习php抽象类的实现方法

2025/8/2 8:04:13发布3次查看
复制代码
例2,php抽象类的例子
title = $title; $this->firstname = $firstname; $this->lastname = $mainname; $this->salary = $salary; } public function firstname() {
return $this->firstname; } public function getlastname() {
return $this->lastname; } public function setratio( $num ) {
$this->ratio=$num; } public function getratio() {
return $this->ratio; } public function gettitle() { return $this->title; } public function getsalary() {
return ($this->salary - $this->ratio); } public function getfullname() {
return {$this->firstname} . {$this->lastname}; } function getsummaryline() {
$base = $this->title ( $this->lastname, ; $base .= $this->firstname ); return $base; }}//定义抽象类
abstract class employeewriter { abstract static function write( employee $shopproduct );}class textemployeewriter extends employeewriter {
static function write( employee $shopemployee ) { $str = {$shopemployee->gettitle()}: ; $str .= $shopemployee->getfullname(); $str .= ({$shopemployee->getsalary()})\n; print $str; }}$developer1 = new employee(a, a1, a2, 5.99 );
textemployeewriter::write( $developer1 );?>
复制代码
榆林分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product