php类继承实例
作者:admin 日期:2012-04-10
PHP代码
- <?php
- class Person
- {
- public $name, $age, $sex;
- public function __construct($name, $age, $sex)
- {
- $this->name = $name;
- $this->age = $age;
- $this->sex = $sex;
- }
- }
- class Child extends Person
- {
- public function say($word)
- {
- echo($word);
- }
- }
- $Child = new Child("田志刚", 30, "男");
- $Child->say("hello");
- echo($Child->name);
- //输出结果:hello田志刚
- ?>
[本日志由 admin 于 2012-04-13 01:25 PM 更新]
上一篇: PHP htmlentities和html_entity_decode下一篇: ASP获取文件的最后修改时间
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: php
相关日志:
评论: 0 | 引用: 0 | 查看次数: 1718
发表评论
广告位