php电子书

源代码在线查看: 4-8-1.php

软件大小: 804 K
上传用户: Kunlun_mrpii
关键词: php 电子书
下载地址: 免注册下载 普通下载 VIP

相关代码

				4-8-1.php				组合								class User{					private $name = "tom";					public function getName(){						return $this->name;					}				}				class Teacher{					private $lengthOfService = 5; // 工龄						public function getLengthOfService(){						return $this->lengthOfService;					}				}				// 上面的类中的set方法就不写了.				// 如果有个研究生,既是学生也算工龄. 				class GraduateStudent extends User {					private $teacher ;					public function __construct(){						$this->teacher = new Teacher();							}						public function getLengthOfService(){						return $this->teacher->getLengthOfService();					}				}				$graduateStudent = new GraduateStudent();				echo "name is ".$graduateStudent->getName()."";				echo "lengthOfService is ".$graduateStudent->getLengthOfService();								?>			

相关资源