博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP类与继承
阅读量:7295 次
发布时间:2019-06-30

本文共 1030 字,大约阅读时间需要 3 分钟。

name = $name; $this->age = $age; } public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function setAge($age) { $this->age = $age; } public function getAge() { return $this->age; } public function SayHello() { printf("
name:%s,age:%d",$this->name,$this->age); } } $person = new Person("zhangsan", 20); $person->SayHello(); class Student extends Person { private $work; function __construct($name,$age,$work) { parent::__construct($name, $age); $this->work = $work; } public function setWork($work) { $this->work = "学生"; } public function getWork() { return $this->work; } public function Introduce() { printf("
name:%s,age:%d,work:%s",$this->getName(),$this->getAge(),$this->getWork()); } } $student = new Student("wangwu", 18, "学生"); $student->SayHello(); $student->Introduce();?>

 

转载于:https://www.cnblogs.com/huangzelin/p/3504363.html

你可能感兴趣的文章
导出excel(jxl)
查看>>
Mysql中utf8和utf8mb4区别
查看>>
LeetCode:Isomorphic Strings - 同构的字符串
查看>>
运营每日读
查看>>
AutoHotKey脚本:帝国时代(罗马复兴)秘籍快速输入
查看>>
MySql-Binlog协议详解-报文篇
查看>>
正则表达式之道
查看>>
vim多行缩进
查看>>
JavaScript运行机制
查看>>
C#与独孤九剑
查看>>
第拾貳章學習 Lisp 3rd Edition, Winston & Horn
查看>>
那些新鲜的玩意——OpenDNS
查看>>
我的友情链接
查看>>
Jenkins 可扩展持续集成引擎全流程(自动构建-自动部署)
查看>>
Linux添加硬盘
查看>>
STP
查看>>
BGP详解1
查看>>
再探C++Primer (4)指针、引用、对象和内存
查看>>
Java 位运算符
查看>>
BlockingQueue学习
查看>>