In the study of PHP language, we can know that PHP4 is unable to achieve multiple inheritance. So what about PHP5? We conducted a test on PHP5 and found that the implementation of PHP5 multiple inheritance was very simple.
How to use PHP upload class upload.php
How to use PHP Ajax to implement a non-flush upload of images
The concrete use method of analytic PHP5 destructor
The specific application of PHP5 magic function
PHP mysqli How to connect to MySQL database
The following is the specific code for PHP5 multiple inheritance:
<? PHP5 interface---and java a bird-like ~ Halo 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; }}//single-Inheritance multi-implementation class Extendsmorecls extends Absclsone implements ifone,iftwo{var $id; private static $priVar = "Private"; function construct () {//php5 constructor self:: $priVar = "Set Private"; $this->id=0; } function Destruct () {//Release function 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 ();//Call static method echo "<br>"; ?>
The structure of the output is
Kj0213200static Functionextendsmorecls Destruct
The above is the simple implementation of PHP5 multiple inheritance of the content of the sample code, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!