By studying the PHP language, we can know that PHP4 cannot implement multiple inheritance. So what about PHP5? We conducted a test on PHP5 and found that the implementation method of multiple inheritance in PHP5 is very simple.
PHPUploadSpecific usage of class upload.php
How to use PHP Ajax to achieve refresh-free upload of images
Analysis of the specific use of PHP5destructor
Specific application of PHP5 magic function
The following is the specific code for PHP5 multiple inheritance: The output structure is
The above is a sample code to simply implement multiple inheritance in PHP5 For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!<? //PHP5 接口 ---跟 JAVA一个鸟样~ 晕 interface IFOne{ function getName(); } interface IFTwo{ function getID(); } //PHP 抽象类 abstract class AbsClsOne{ var $name; function setName($name){ $this->name=$name; } } abstract class AbsClsTwo{ var $id; function setID($id){ $this->id=$id; } } //单继承 多实现 class ExtendsMoreCls extends AbsClsOne implements IFOne,IFTwo{ var $id; private static $priVar="private"; function construct(){//PHP5的 构造函数 self::$priVar="set private"; $this->id=0; } function destruct(){//释构函数 echo "ExtendsMoreCls destruct"; } function getName(){ return $this->name; } function getID(){ return $this->id; } public static function clsStaticFunc(){ echo "static function"; } } $emc=new ExtendsMoreCls(); $emc->setName("kj021320"); echo $emc->getName(); echo "<br>"; echo $emc->getID(); echo "<br>"; ExtendsMoreCls::clsStaticFunc();//调用静态方法 echo "<br>"; ?>