php类的定义与继承用法实例

前端之家收集整理的这篇文章主要介绍了php类的定义与继承用法实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了PHP类的定义与继承用法分享给大家供大家参考。具体如下:

PHP;"> name = $namec; $this->age = $agec; } protected function getmessage() { return "姓名:".$this->name."
"."年龄:".$this->age; } function __tostring() { return "姓名:".$this->name."
"."年龄:".$this->age; } function __destruct() { echo "
I am dead!"; } function __call($key,$args) { echo "
","你调用方法名不存在:$key","
"; echo "你调用的参数是:",var_dump($args); } final function getf() { echo "I am getf"; } } class xinxin extends people { function getname() { echo $this->getmessage(); echo '
'; echo parent::getmessage(); echo '
'; return "I am xinxin"; } function getmessage() { return "I am zilei getmessage
"; } function getff() { echo "I am new getf"; } } $pp = new people("小弟","33"); //$pp->name = "小明"; //$pp->age = "88"; echo $pp->name; echo ' '; echo $pp->age; echo '

'; $xx = new xinxin("小小","13"); echo $xx->getname(); ?>

希望本文所述对大家的PHP程序设计有所帮助。

原文链接:https://www.f2er.com/php/21564.html

猜你在找的PHP相关文章